Here I'm trying to access WebApi Service in Mvc but im geeting error :
asSeverity Code Description Project File Line Error CS0029 Cannot implicitly convert type 'string' to 'System.Collections.Generic.IEnumerable'
IEnumerable<MasterTab> resResult = result.Content.ReadAsStringAsync().Result; public ActionResult Index() { using(var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:54040/Api/Marketing/"); var responseTask = client.GetAsync("GetMarketing"); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { IEnumerable<MasterTab> resResult = result.Content.ReadAsStringAsync().Result; } else { students = Enumerable.Empty<MasterTab>();ModelState.AddModelError(string.Empty, "Server Error Please Conatct Admin"); } } return View(students); }
IEnumerable<MasterTab> resResult = result.Content.ReadAsStringAsync().Result;Here return type is string. SO, what you need to do is first use string result = assign result; then convert it using newtonsoft or other libraries toIEnumerable<MasterTab>