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

webapi权限常见错误

时间:2018-08-02 15:00:15      阅读:504      评论:0      收藏:0      [点我收藏+]

标签:ace   int   add   control   origin   enable   accept   ati   handle   

webapi权限常见错误

错误一:

Response for preflight has invalid HTTP status code 405.

解决方案:

屏蔽配置文件中的如下代码

   <!--<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>-->

错误二:

No ‘Access-Control-Allow-Origin‘ header is present on the requested resource. Origin ‘http://localhost:2062‘ is therefore not allowed access. The response had HTTP status code 500.
 <!--<add name="access-control-allow-headers" value="accept,origin,token,content-type,Authorization" />-->

解决方案:
跨域造成的,解决跨域即可:

 <httpProtocol>
      <customHeaders>
        <!-- Enable Cross Domain AJAX calls -->
        <add name="Access-Control-Allow-Origin" value="http://localhost:2062" />
        <add name="Access-Control-Allow-Methods" value="GET,POST,PUT,DELETE,OPTIONS"/>
        <add name="Access-Control-Allow-Headers" value="Content-Type,Authorization"/>
      </customHeaders>
    </httpProtocol>

错误三:

The ‘Access-Control-Allow-Origin‘ header has a value ‘http://localhost:2062/‘ that is not equal to the supplied origin. Origin ‘http://localhost:2062‘ is therefore not allowed access.

解决方案:

由于手误造成的,域名后面不能有任何字符或符合

正确:‘http://localhost:2062

错误:‘http://localhost:2062/

 

webapi权限常见错误

标签:ace   int   add   control   origin   enable   accept   ati   handle   

原文地址:https://www.cnblogs.com/zlp520/p/9406730.html

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