在我的ASP.NET Core(.NET Framework)项目中,我的以下控制器操作方法出现上述错误.我可能错过了什么?或者,有什么解决办法吗?:
public class ClientController : Controller
{
public ActionResult CountryLookup()
{
var countries = new List<SearchTypeAheadEntity>
{
new SearchTypeAheadEntity {ShortCode = "US", Name = "United States"},
new SearchTypeAheadEntity {ShortCode = "CA", Name = "Canada"}
};
return Json(countries, JsonRequestBehavior.AllowGet);
}
}
UPDATE:
请注意@NateBarbettini的以下 comments :
-
JsonRequestBehavior
在ASP中已被弃用.NET核心1.0. - 在下面@Miguel的接受响应中,操作方法
does not
的return type
特别需要是JsonResult类型.ActionResult或IActionResult也可以.