[英]ASMX service works on development server, returns 404 when deployed to IIS 7.5
I have a web application in ASP.NET 4.0. 我在ASP.NET 4.0中有一个Web应用程序。 I've added an asmx service, primarily as a source for the autocomplete extender's lookup values.
我添加了一个asmx服务,主要是作为自动完成扩展器的查找值的源。
When I debug on my machine locally, everything works fine. 当我在本地机器上调试时,一切正常。 However, when I deploy the web application to IIS 7.5, I get a HTTP 404 response when trying to send data to the service.
但是,当我将Web应用程序部署到IIS 7.5时,我在尝试将数据发送到服务时收到HTTP 404响应。
I am able to browse to the service definition, see the available operations. 我能够浏览到服务定义,查看可用的操作。 Tellingly, however, when I use the test pages to test the service using POST, I receive an HTTP 404 again.
然而,引人注目的是,当我使用测试页面使用POST测试服务时,我再次收到HTTP 404。
I'm not sure what is going on. 我不确定发生了什么。 I did create the asmx file within my web application and it is deployed in the virtual directory of my otherwise working production application.
我确实在我的Web应用程序中创建了asmx文件,它部署在我正在运行的生产应用程序的虚拟目录中。
Is there an issue with the .asmx file being deployed in the same virtual directory, perhaps? 是否存在将.asmx文件部署在同一虚拟目录中的问题?
I've just encountered the same error, after stumbling over this SO entry: 在遇到这个SO条目后,我刚刚遇到了同样的错误:
Handlers returns 404 error on IIS7.5 integrated pipeline and 处理程序在IIS7.5集成管道上返回404错误
ASMX operation 404s, but ASMX service description doesn't, url routing issue? ASMX操作404s,但是ASMX服务描述没有,url路由问题?
and tried the solution of adding the asmx handler to the web.configs webServer section all was well: 并尝试将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>
You should check the application pool for the web service: 您应该检查Web服务的应用程序池:
I was posting to asmx with jQuery and it worked in test systems, but failed on the production server. 我使用jQuery发布到asmx并且它在测试系统中工作,但在生产服务器上失败了。 I was missing the datatype parameter:
我错过了数据类型参数:
$.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 } });
In Asp.net MVC RouteConfig.cs
you can't have this line: 在Asp.net MVC
RouteConfig.cs
你不能拥有这一行:
routes.RouteExistingFiles = true;
That was throwing me http 404 error. 那是在给我带来http 404错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.