码迷,mamicode.com
首页 > Windows程序 > 详细

ajax调用.net API项目跨域问题解决

时间:2017-08-23 13:26:17      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:bpa   blog   http   mic   handler   false   webserver   解决   tpm   

ajax调用.net API项目,经常提示跨域问题。添加如下节点代码解决:httpProtocol

<system.webServer>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <validation validateIntegratedModeConfiguration="false" />

    <!--解决webpage ajax 跨域等问题-->
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type" />
        <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
      </customHeaders>
    </httpProtocol>
    
    <modules>
      <remove name="ApplicationInsightsWebTracking" />
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
    </modules>
  </system.webServer>

 

ajax调用.net API项目跨域问题解决

标签:bpa   blog   http   mic   handler   false   webserver   解决   tpm   

原文地址:http://www.cnblogs.com/itslives-com/p/CORS.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!