i am doing a sample where i require stored procedure result have to be displayed in view(created strongly typed view by choosing details in dropdown).from service i am getting result in this format

[{"studentID":1,"studentName":"Suja","StudentDepaertment":"Economics"}] but i get error

The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[StudentForm.sp_join_details_Result]', but this dictionary requires a model item of type 'StudentForm.sp_join_details_Result'.


   public ActionResult Details(string name)
        studentEntities data = new studentEntities();
        List<sp_join_details_Result> model = null;
        var client = new HttpClient();
        client.BaseAddress = new Uri("http://localhost:99991/");
        var response = client.GetAsync(string.Format("api/Details?name={0}", name)).Result;
        var responseBody = response.Content.ReadAsStringAsync();
        var productString = Newtonsoft.Json.JsonConvert.DeserializeObject<List<sp_join_details_Result>>(responseBody.Result);
        return View(productString);


 @model EmployAppraisalForm.sp_join_details_Result

ViewBag.Title = "Details";



<div class="display-label">
     @Html.DisplayNameFor(model => model.studentID)
<div class="display-field">
    @Html.DisplayFor(model => model.studentID)

<div class="display-label">
     @Html.DisplayNameFor(model => model.studentName)
<div class="display-field">
    @Html.DisplayFor(model => model.studentName)

I know i have to covert the response of service to result that could be displayed in view,to which i should convert ?Please help me in this.....

Related posts

Recent Viewed