首页 > Windows开发 > 详细

webapi权限常见错误

时间:2018-08-02 14:32:02      阅读:187      评论:0      收藏:0      [点我收藏+]

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权限常见错误

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!