webAPI 405
web.config 配置
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
<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" />
<!--<add name="WebDAV" path="*" verb="PROPFIND,PROPPATCH,MKCOL,PUT,COPY,DELETE,MOVE,LOCK,UNLOCK" modules="WebDAVModule" resourceType="Unspecified" requireAccess="None" />-->
</handlers>
</system.webServer>
<appSettings>
<add key="cors-origins" value="http://www.liuyanzhen.com" />
<add key="cors-headers" value="*" />
<add key="cors-methods" value="GET,POST,DELETE,PUT" />
</appSettings>
WebApiConfig.cs 配置
public static void Register(HttpConfiguration config)
{
// Web API 配置和服务
config.EnableCors(new EnableCorsAttribute(
ConfigurationTool.AppSetting("cors-origins"),
ConfigurationTool.AppSetting("cors-headers"),
ConfigurationTool.AppSetting("cors-methods")
)); // Web API 路由
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApiAction",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
//config.Routes.MapHttpRoute(
// name: "DefaultApi",
// routeTemplate: "api/{controller}/{id}",
// defaults: new { id = RouteParameter.Optional }
//);
}
webAPI 405的更多相关文章
- webapi 405 method not allowed
问题的原因:创建webapi controller时,习惯创建了mvc的controller,而非api controller.导致引用包有问题. 这两天搞webapi开发的时候,遇见了405错误. ...
- webapi 发布接口报405错误(angularjs2.0)
参考链接:http://www.cnblogs.com/shenbin/p/5680976.html web访问接口报405错误,以前的jQuery访问方式访问接口没有问题. 但是换成angularj ...
- WebApi PUT、DELETE请求时出现405 - 不允许用于访问此页的 HTTP 谓词。
开发时,新建WebApi项目需要用到Restful规范,此时请求有POST\PUT\DELETE\GET等请求 此时需要在web.config中加入 <system.webServer> ...
- WebApi HTTP Put 405 Method not allowed
总结列表: 1. There is already an open DataReader associated with this Connection which must be closed fi ...
- ASP.Net WebAPI HttpDelete/PUT方法运行或发布到生产服务器上后出现405(Method Not Allowed)错误的解决办法
原文:ASP.Net WebAPI HttpDelete/PUT方法运行或发布到生产服务器上后出现405(Method Not Allowed)错误的解决办法 本文只是个人的理解和学习记录,如果觉得本 ...
- [转载]aspnet webapi 跨域请求 405错误
写了个webapi给同事用ajax调用,配置完跨域以后get请求完全没问题,post就一直报405错误,花了半天时间就是解决不了,后来在网上看到一博主的帖子才知道原来是webapi 默认的web.co ...
- aspnet webapi 跨域请求 405错误
跨域,请求按要求配置完毕之后,options预请求老是报错.原因是webapi 默认的web.config有配置 <handlers> <remove name="Exte ...
- cors解决webapi post时报错405 method not allowed
nuget控制台敲入以下命令:Install-Package Microsoft.AspNet.WebApi.Cors –IncludePrerelease 打开WebApiConfig.cs添加如下 ...
- Asp.net WebApi Put模式调用,“HTTP 错误 405.0 - Method Not Allowed”解决方法
IIS10.0在部署了WebAPI之后,默认是不支持Put模式调用的.需要按照下面方法启用. 步骤一:在IIS管理界面要支持Put模式的IIS站点,选择 "功能视图". 步骤二:选 ...
随机推荐
- Javascript短路表达式
短路表达式:作为"&&"和"||"操作符的操作数表达式,这些表达式在进行求值时,只要最终的结果已经可以确定是真或假,求值过程便告终止,这称之为短 ...
- 「kuangbin带你飞」专题二十 斜率DP
layout: post title: 「kuangbin带你飞」专题二十 斜率DP author: "luowentaoaa" catalog: true tags: mathj ...
- Python学习笔记——模块
使用模块 python中包的组织方式是模块,一个使用其它模块的例子如下: # Filename: using_sys.py import sys print 'The command line arg ...
- JQuery插件开发格式
原地址 一.jQuery扩展 1.$.extend(object) 类似于.Net的扩展方法,用于扩展jQuery.然后就可以用$.的方式调用. $(function(){ $.extend({ fu ...
- sourceinsight----tabsiplus颜色配置文件
参考: http://blog.csdn.net/orbit/article/details/7585607 下面是我的颜色配置 http://files.cnblogs.com/pengdongli ...
- CENTOS设置MYSQL字符集
CENTOS设置MYSQL字符集 show variables like 'character_set%'; vim etc/my.cnf 修改成如下: [client] port=3306 sock ...
- 【转】Ehcache详细解读
Ehcache 是现在最流行的纯Java开源缓存框架,配置简单.结构清晰.功能强大,最初知道它,是从Hibernate的缓存开始的.网上中文的EhCache材料 以简单介绍和配置方法居多,如果你有这方 ...
- Unitity 常用工具类
ylbtech-Unitity_C#: Unitity 常用代码 1.A,效果图返回顶部 1.B,源代码返回顶部 1,日期字符串 using System; using System.Xml; / ...
- FormData上传文件同时附带其他参数
前端js代码: function fileSubmit() { var formData = new FormData(); formData.append(].files[]); var type ...
- 解决no declaration can be found for element 'context:component-scan'
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...