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/

错误四:

404 Not Found

解决方案:

增加两个modules任意一个都可以解决404,但如果验证权限会出现405错误;

<modules>
      <remove name="UrlRoutingModule-4.0"/>
      <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition=""/>
    </modules>

    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule" />
    </modules>

错误五:

Failed to load http://192.168.31.110:8014/api/Login/CheckLogin: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.31.110:8013' is therefore not allowed access.

解决方案:

 <httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type,x-xsrf-token,X-Requested-With" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
错误六:
The requested resource does not support http method 'OPTIONS
解决方案: 错误七:
<!--IIS7/7.5上必须加这个配置,否则访问报错-->
23 <modules runAllManagedModulesForAllRequests="true">
24 <remove name="WebDAVModule" />
25 </modules>
26 <validation validateIntegratedModeConfiguration="false" />
27 <handlers>
28 <remove name="WebDAV" />
29 <remove name="WebAPI_64bit" />
30 <remove name="WebAPI_32bit" />
31 <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
32 <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
33 <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
34 <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" resourceType="Unspecified" requireAccess="Script" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
35 <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" resourceType="Unspecified" requireAccess="Script" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
36 <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" resourceType="Unspecified" requireAccess="Script" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
37 <add name="WebAPI_64bit" path="*" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv4.0,bitness64" />
38 <add name="WebAPI_32bit" path="*" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv4.0,bitness32" />
39 </handlers>

-----
错误八:
      <remove name="OPTIONSVerbHandler" />
这个是罪魁祸首,移除即可

HTTP Error 403.14 - Forbidden

Web 服务器被配置为不列出此目录的内容。

解决方案:

 
jQuery.support.cors = true;//设定支持跨域

webapi权限常见错误的更多相关文章

  1. webapi发布常见错误及解决方案

    webapi发布常见错误及解决方案 错误一: 错误:404 (Not Found) 解决方案: 在  <system.webServer>节点中添加如下模块: <modules ru ...

  2. iis 部署webapi常见错误及解决方案

    iis 部署webapi常见错误及解决方案 错误一: 原因:asp.net web api部署在Windows服务器上后,按照WebAPI定义的路由访问,老是出现404,但定义一个静态文件从站点访问, ...

  3. [置顶] Web用户的身份验证及WebApi权限验证流程的设计和实现 (不是Token驗證!!!不是Token驗證!!!都是基於用户身份的票据信息驗證!!!)

     转发 http://blog.csdn.net/besley/article/details/8516894 不是Token驗證!!!不是Token驗證!!!都是基於用户身份的票据信息驗證!!! [ ...

  4. Hadoop - Mac OSX下配置和启动hadoop以及常见错误解决

    0. 安装JDK 参考网上教程在OSX下安装jdk 1. 下载及安装hadoop a) 下载地址: http://hadoop.apache.org b) 配置ssh环境 在terminal里面输入: ...

  5. MySQL常见错误类型

    MySQL常见错误类型:1005:创建表失败1006:创建数据库失败1007:数据库已存在,创建数据库失败1008:数据库不存在,删除数据库失败1009:不能删除数据库文件导致删除数据库失败1010: ...

  6. (转)Hadoop之常见错误集锦

     Hadoop之常见错误集锦            下文中没有特殊说明,环境都是CentOS下Hadoop 2.2.0.1.伪分布模式下执行start-dfs.sh脚本启动HDFS时出现如下错误:   ...

  7. iOS-cocoapods安装与使用以及常见错误

    前言 CocoaPods是一个负责管理iOS项目中第三方开源代码的工具. 二.安装由于网上的教程基本都大同小异,但细节之处还不是很完善,所以借机会在这里补充下:注:要使用CocoaPods,那就要下载 ...

  8. Elasticsearch 集群和索引健康状态及常见错误说明

    之前在IDC机房线上环境部署了一套ELK日志集中分析系统, 这里简单总结下ELK中Elasticsearch健康状态相关问题, Elasticsearch的索引状态和集群状态传达着不同的意思. 一.  ...

  9. IIS7常见错误及解决方法

    IIS7常见错误及解决方法   问题一:HTTP 错误 500.19 - Internal Server Error 无法访问请求的页面,因为该页的相关配置数据无效.  详细错误信息模块 IIS We ...

随机推荐

  1. kibana-4.6.3-linux-x86_64.tar.gz的安装(图文详解)(升级)

     前期博客 kibana-4.6.3-linux-x86_64.tar.gz的下载(图文详解) 因为,我的机器情况是如下: 1.上传 [hadoop@master app]$ rz [hadoop@m ...

  2. HttpClient由Client客户端上传File文件流至Server服务端

    客户端方法 public static void main(String[] args) { File file=new File("E:\\lucene\\rev\\全年平台受理量.doc ...

  3. 10 华电内部文档搜索系统 search03

    上一节讲解了怎么在Struts 2下面使用内置对象传值,在Struts 2下面是用Session或者Request存放对象.在Struts 2下面是用内部对象传值,和JSP页面下面稍微有些不同.但是实 ...

  4. c# winform 解决PictureBox 无法打印全部图片的问题

    一.   问题描述 在页面使用PictureBox 加载资料图片后,点击“打印”,只能打印图片首页,较大图片则无法全部打印. 二.   原因分析 PictureBox中打印图片时没有设置继续打印相关属 ...

  5. Linux ag命令

    一.简介 Ag是用C++写的,搜索速度快,比grep更有效率. 二.安装 RHEL7+ rpm -Uvh http://download.fedoraproject.org/pub/epel/7/x8 ...

  6. Nginx 事件基本处理流程分析

    说明:本文章重点关注事件处理模型.有兴趣的同学可以去http://tengine.taobao.org/book/查找更多资料.Tengine应该是淘宝基于Nginx自己做的修改.这个地址的文档还在不 ...

  7. easyui combogrid 下拉框 智能输入

    1. 后台代码 using System;using System.Collections;using System.Collections.Generic;using System.Linq;usi ...

  8. 通过MySql自动同步刷新redis

    在服务端开发过程中,一般会使用MySQL等关系型数据库作为最终的存储引擎,Redis其实也可以作为一种键值对型的数据库,但在一些实际场景中,特别是关系型结构并不适合使用Redis直接作为数据库.这俩家 ...

  9. static 和final

    1.static       static关键字可以用来修饰类的变量,方法和内部类.static是静态的意思,也是全局的意思,它定义的东西属于全局,与类相关,不与具体实例相关.就是说它调用的时候,只是 ...

  10. 12306GT多线程、分流免费抢票工具使用心德

    大事记背景 我相信很多远游他乡的朋友每逢佳节都会遇到一个难题,就是购票难,这个难题有多难呢?经常在12306官网购票的小伙伴应该知道每个地方的放票时间是不一样的,但是逢年过节的那几天即使你在放票几分钟 ...