在我的 MVC 项目中,我从 WEB API 接收数据。
public ActionResult Index()
{
if (Session["LoggedInUser"] == null)
{
var Data = GetPublicationsData();
return View(Data);
}
else
{
return View();
}
}
public ProductCategoryInfo GetPublicationsData()
{
ProductCategoryInfo model = new ProductCategoryInfo();
// Fetch Data from WEB API AND RETURN MODEL
IRestResponse response = client.Execute(request);
ProductCategoryInfo responses = JsonConvert.DeserializeObject<ProductCategoryInfo>(response.Content);
return model;
}
成功从 Web API获取数据,但是当我检查VAR DATA变量时,它显示为null。