public ActionResult Index(string category) { JsonpResult jr = new JsonpResult(); jr.JsonRequestBehavior = JsonRequestBehavior.AllowGet; TypeItImage img = new TypeItImage(); //go to wikipedia to get some data! if (category == null) { ViewBag.Message = "Your category is empty"; } else if (category == "Test") { img.Src = "http://paradoxoff.com/files/2012/12/hitachi-seaside-park-2.jpg"; img.Word = "Flowers"; jr.Data = img; return(jr); } else //real data { WikiPediaService srv = new WikiPediaService(); YoutubeService youtubeSrv = new YoutubeService(); //for example this will return for category = "dog" //["dog",["Dog","Doge of Venice","Dogma","Dog breed","Dogfight","Dogwood","Dog sled","Doge's Palace, Venice","Dog Day Afternoon","D\u014dgen"]] try { List <WikiImage> imgs = srv.GetImages(category); if (imgs.Count > 0) { img.Src = imgs[0].Uri; img.Word = imgs[0].Title; //grab the reward video img.RewardVideo = youtubeSrv.GetVideo(category); jr.Data = img; return(jr); } ViewBag.Message = "No images were found! "; } catch (System.Exception ex) { // System.Diagnostics.Debug.WriteLine(ex.Message); ViewBag.Message = "There was an error! " + ex.Message; } } return(View()); }