程序没问题,用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>