Jquery Asp.net页面Web方法在服务器上不起作用,但在本地主机上可以正常工作
页面Samples/jssample2.aspxJquery Asp.net页面Web方法在服务器上不起作用,但在本地主机上可以正常工作,jquery,asp.net,web-services,Jquery,Asp.net,Web Services,页面Samples/jssample2.aspx [WebMethod] [System.Web.Script.Services.ScriptMethod()] public static string HelloPage() { return "g"; } } jQuery: jQuery.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url:
[WebMethod]
[System.Web.Script.Services.ScriptMethod()]
public static string HelloPage()
{
return "g"; }
}
jQuery:
jQuery.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "http://myhost.com/Samples/jssample2.aspx/HelloPage",
data: "{}",
dataType: "json" });
看起来我的web服务(asmx)已禁用(当我将其发布到服务器时)
但是我可以在浏览器中访问Myhosting.com/jssample2.aspx/HelloPage(我看到默认的soap描述)
在FIDDLER POST HTTP/1.1 FIDDLER响应中未找到HTTP/1.1 404
jquery.ajax错误也返回404。也许我会在web.config?或web方法(属性)中添加一些内容?
IIS设置
.asmx D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet\u isapi.dll
我的httpHandlers
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
我只是创建了一个简单的解决方案并将其发布到web服务器上,一切正常。看起来问题在路径中。问题在web.config中。
我从加载项httpmodules部分删除路由器设置
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
您应该提供错误消息并更恰当地描述问题。嘿,您能粘贴完整的web.config文件吗?我也有同样的问题。