在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最好指定域名。
标签:Control,Web,跨域,配置,MVC,NET From: https://www.cnblogs.com/yuejin/p/16965679.html