Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 使用IHTTPActionResult返回JSONP以实现CORS请求兼容性_Asp.net Mvc_Jsonp_Asp.net Mvc 5 - Fatal编程技术网

Asp.net mvc 使用IHTTPActionResult返回JSONP以实现CORS请求兼容性

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);

有没有办法使IHTTPActionResult JSONP代替JSON或XML

以下是我试图返回JSONP的控制器操作:

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();
}
}
}

也许这会有帮助?