Asp.net mvc 使用IHTTPActionResult返回JSONP以实现CORS请求兼容性
有没有办法使IHTTPActionResult JSONP代替JSON或XML 以下是我试图返回JSONP的控制器操作:Asp.net mvc 使用IHTTPActionResult返回JSONP以实现CORS请求兼容性,asp.net-mvc,jsonp,asp.net-mvc-5,Asp.net Mvc,Jsonp,Asp.net Mvc 5,有没有办法使IHTTPActionResult JSONP代替JSON或XML 以下是我试图返回JSONP的控制器操作: public IHttpActionResult getCountry() { LocationDB db = new LocationDB(); try { IEnumerable<Country> countries = db.getCountries(); return Ok(countries);
public IHttpActionResult getCountry()
{
LocationDB db = new LocationDB();
try
{
IEnumerable<Country> countries = db.getCountries();
return Ok(countries);
}
catch
{
return NotFound();
}
}
public IHttpActionResult getCountry()
{
LocationDB=新的LocationDB();
尝试
{
IEnumerable countries=db.getCountries();
返回Ok(国家);
}
接住
{
返回NotFound();
}
}
}也许这会有帮助?