I am new to MVC and I want to get the data out of my model in view, my code is given below and the corresponding class as well.when I tried to do using the existing code it gives me error,The model item passed into the dictionary is of type .. but this dictionary requires a model item of type
public ActionResult Index(string userid)
{
var model = new AssociationsViewModel()
{
userid = userid,
str = getAssociations(userid)
};
//AssociationsViewModel.RootObject obj = new AssociationsViewModel.RootObject();
// List< AssociationsViewModel.RootObject> obj2 = model.userlist;
//AssociationsViewModel flight = Newtonsoft.Json.JsonConvert.DeserializeObject<AssociationsViewModel>(model);
return View(model);
}
public JsonResult getAssociations(string id)
{
var inputData = new Dictionary<string, string>()
{
{ "databaseName", string.IsNullOrEmpty( Helper.databasename)? "" : Helper.databasename},
{ "sourceUrl", Helper.sourceurl},
{ "physicianId", id },
};
var str = _client.FetchData
(
"associations/getAssociations",
inputData
);
return Json( str.Content.ToString());
}
public class AssociationsViewModel
{
public string userid { get; set; }
public System.Web.Mvc.JsonResult str { get; set; }
public class RootObject
{
public string firstname { get; set; }
public string lastname { get; set; }
public string email { get; set; }
}
public List<RootObject> userlist { get; set; }
public AssociationsViewModel()
{
}
}