I have a web application in ASP.NET 4.0. I've added an asmx service, primarily as a source for the autocomplete extender's lookup values.
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 w开发者_高级运维hen trying to send data to the service.
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.
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.
Is there an issue with the .asmx file being deployed in the same virtual directory, perhaps?
I've just encountered the same error, after stumbling over this SO entry:
Handlers returns 404 error on IIS7.5 integrated pipeline and
ASMX operation 404s, but ASMX service description doesn't, url routing issue?
and tried the solution of adding the asmx handler to the web.configs webServer section all was well:
<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:
- Is it configured to use the correct .NET version
- Check the identity
- Check the managed pipeline mode; some applications require Classic to be used
I was posting to asmx with jQuery and it worked in test systems, but failed on the production server. 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:
routes.RouteExistingFiles = true;
That was throwing me http 404 error.
I got a 404 when using IIS Express. I switched to using full IIS:
(right-click project > properties. Switch to 'Local IIS' under 'Servers')
If prompted, say yes to creating the virtual directory. (You can also do this manually by clicking 'Create Virtual Directory')
Make sure you set the 'Project Url' to the path to the webservice, and 'Specific page' to the name of your .asmx
service.
After this, I got a different 404.3 error (see here - "The page you are requesting cannot be served because of the extension configuration." error message)
The .asmx
web service was using .NET 4.7.2, but I needed the following settings (under 'Turn Windows features on or off' in Windows). It then worked (I've shown the other main settings I'm using for IIS):
精彩评论