当前位置: 代码迷 >> Web Service >> 本机上可以,置服务器上后,用ajax模拟post请求报错 “405 Method not allowed”
  详细解决方案

本机上可以,置服务器上后,用ajax模拟post请求报错 “405 Method not allowed”

热度:234   发布时间:2016-05-02 02:21:24.0
本机上可以,放服务器上后,用ajax模拟post请求报错 “405 Method not allowed”
程序没问题,用ajax测试的时候,在本地可以,把url换成服务器的,就进不去了。 

Status Code:405 Method Not Allowed

程序:

var json = ....... . //json格式的字符串
$.ajax({ 
url: "http://localhost:3770/XXXService.svc/InsertCCFB", 
type: "POST", 
contentType: "application/json", 
data: '{ "ccfb":' + json + '}',
dataType: "json", 
success: function (returnValue) { 
alert(returnValue); 
}, 
error: function () { 
alert('没有进入'); 

});
 

        [WebInvoke(Method = "POST", UriTemplate = "/InsertCCFB", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
        string InsertCCFB(CCFB ccfb);


网上查了很多资料,iis上面
1)加了MIME类型(扩展名 .json   类型text/json)
2)处理映射程序也添加了 执行路径 *.json , 谓词GET,POST
3)WebDAV的谓词限制也改成了全部为此

但还是405错误。。
------解决方案--------------------
服务器地址可以在ie中打开吗
------解决方案--------------------
添加这个配置也不行的?
<handlers>
  <remove name="WebDAV" />
  <add name="WebDAV" path="*" verb="*" modules="WebDAVModule"
      resourceType="Unspecified" requireAccess="None" />
</handlers>
------解决方案--------------------
<system.webServer>
    <modules>
        <remove name="WebDAVModule" />
    </modules>
    <handlers>
        <remove name="WebDAV" />
    </handlers>
</system.webServer>
  相关解决方案