ASP.NET MVC 4 Catch-all only firing on local, not on remote requests

asp.net-mvc, asp.net-mvc-4, iis, iis-7.5

Solution

I have had problems with IIS showing default errors instead of .NET errors, which I've fixed with the following in `system.webServer` in the web.config:

<httpErrors existingResponse="PassThrough"/>

I think this would happen if in your `UnknownUrl` action you are setting `Response.StatusCode = 404;`. By default IIS sees you are returning an error code so shows a default error message, which you can override with that config setting.

I'm not sure this would be different on local v remote but could be worth a try.

Problem

In an ASP.NET MVC 4 application, we have set up a catch-all route as follows: ``` routes.MapRoute( name: "UnKnown", url: "{*url}", defaults: new { controller = "CatchAll", action = "UnknownUrl" }); ``` The UnknownUrl method in the CatchAllController correctly loads its view in our development environment. However, the production IIS 7.5 shows its standard 404 page if a non-existing remote request arrives. A local request, sent using RDP on the server itself, works fine. The web.config is set tp ``` <customErrors mode="Off"/> ``` What other difference is there between a local call and a remote call? How can we make the MVC HttpHandler catch those requests? A hint might be that we were also unable to make the IIS show any detailed status 500 error messages when called remotely.

Original source

Related problems