In my ASP.NET Core (.NET Framework) project, I'm getting above error on my following Controller Action method. What I may be missing? Or, are there any work arounds?:
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:
Please note folowing comments from @NateBarbettini below:
JsonRequestBehavior
has been deprecated in ASP.NET Core 1.0.
- In accepted response from @Miguel below, the
return type
of action method does not
specifically need to be of type JsonResult. ActionResult or IActionResult works too.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…