[英]404 Error when trying to access Web API 2 Service deployed to IIS 7.5
[英]ASMX service works on development server, returns 404 when deployed to IIS 7.5
我在ASP.NET 4.0中有一个Web应用程序。 我添加了一个asmx服务,主要是作为自动完成扩展器的查找值的源。
当我在本地机器上调试时,一切正常。 但是,当我将Web应用程序部署到IIS 7.5时,我在尝试将数据发送到服务时收到HTTP 404响应。
我能够浏览到服务定义,查看可用的操作。 然而,引人注目的是,当我使用测试页面使用POST测试服务时,我再次收到HTTP 404。
我不确定发生了什么。 我确实在我的Web应用程序中创建了asmx文件,它部署在我正在运行的生产应用程序的虚拟目录中。
是否存在将.asmx文件部署在同一虚拟目录中的问题?
在遇到这个SO条目后,我刚刚遇到了同样的错误:
ASMX操作404s,但是ASMX服务描述没有,url路由问题?
并尝试将asmx处理程序添加到web.configs webServer部分的解决方案一切都很好:
<system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules runAllManagedModulesForAllRequests="true"/> <handlers> <add verb="*" path="*.asmx" name="asmx" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </handlers> </system.webServer>
您应该检查Web服务的应用程序池:
我使用jQuery发布到asmx并且它在测试系统中工作,但在生产服务器上失败了。 我错过了数据类型参数:
$.ajax({ type: "POST", contentType: "application/json; charset=utf-8", data: JSON.stringify({ //Data goes here }), dataType: "json", //<<<<<<<<< This is critical for the post to succeed in production. Without it we get a 404. url: "/yourPathHere/yourEndpoint.asmx/methodName", error: function (jqxhr, status) { //error handler }, success: function (data, status) { //succes handler } });
在Asp.net MVC RouteConfig.cs
你不能拥有这一行:
routes.RouteExistingFiles = true;
那是在给我带来http 404错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.