1.web.config:
2.在每个controller加方法
public string Options()
{
return null; // HTTP 200 response with empty body
}
方法2:
http://enable-cors.org/server_aspnet.html
Install-Package Microsoft.AspNet.WebApi.Cors
无需在web.config里面新增
//var corsAttr = new EnableCorsAttribute("http://180.76.160.7:8088", "Content-Type", "GET, POST, PUT, DELETE, OPTIONS");
var corsAttr = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(corsAttr);
//config.EnableCors();
网友评论