.NET MVC跨域配置
在Web.config中配置
<configuration> <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*"/> <add name="Access-Control-Allow-Headers" value="Content-Type,Accept,X-Requested-With,Token"/> <add name="Access-Control-Allow-Methods" value="GET,POST,OPTIONS"/> </customHeaders> </httpProtocol> </system.webServer> </configuration>
注意:在生产环境中,为了安全,Access-Control-Allow-Origin最好指定域名。