ASP.NET MVC 配置允许跨域访问

  • A+
所属分类:ASP.NET MVC

ASP.NET MVC 配置允许跨域访问

在web.config文件中的 system.webServer 节点下 增加如下配置

  1. <httpProtocol>  
  2.             <customHeaders>  
  3.                 <add name="Access-Control-Allow-Origin" value="*" />  
  4.                 <add name="Access-Control-Allow-Headers" value="*" />  
  5.                 <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE" />  
  6.             </customHeaders>  
  7. </httpProtocol>  
钰玺

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: