Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


when I manually set the HTTP Status of my response stream to, say, 404 or 503, IIS renders up the stock IIS content/view, instead of my custom view.

When I do this with the web development server (AKA. Cassini), it works correctly (that is, my content is displayed and the response.statuscode == my entered data).

Is there any way I can override this behaviour?

How To Replicate

Make a default ASP.NET MVC1 web application. Add the following route

public static void RegisterRoutes(RouteCollection routes)

        new { controller = "Home", action = "Index" }


Now replace the the HomeController's Index method with...

public class HomeController : Controller
    public ActionResult Index()
        Response.StatusCode = 404;
        return View();
share|improve this question
up vote 15 down vote accepted

Ok - found the answer. As I expected, IIS is hijacking my non 200 responses. Not sure (ie. I'm not sure if this is the default behaviour OR it's because of a setting one of the team members updated in the machine config, etc...).

Anyways, the key here is tell IIS to not handle any non-200 status result resources.

How? Config entry in the web.config.

    <httpErrors errorMode="DetailedLocalOnly" existingResponse="PassThrough"/>
    .... snipped other IIS relevant elements ... 

Now, the key here is existingResponse="PassThrough" . That bad boy tells IIS to leave my resources alone if the HTTP status code != 200.

Want more info? Sure: Read More about this Element on the Official IIS Website.

share|improve this answer
httpErrors is like Error Pages -> 500 -> Edit Feature Settings -> "Detailed Errors" ?_‌​7-5_ – Kiquenet Oct 6 '15 at 17:20

Be carefull with that approach in general. You should NOT render a view on 404 status.

  • I think when a error status code is returned, IIS returns the status error page that is registered with it - not the output from processing. So, you can put a HTML page there (or a link to an aspx page). has a nice explanation how to set up an error page.

  • But that is irrelvant. Quite a number of browsers by default do NOT show that output, but something set in the browser. So, if you rely on people seeing your 404 page - that may not happen. They may see the 404 page that is set up in the browser for them.

share|improve this answer
Why shouldn't i be rendering a view on a 404? i want a custom page, and my page might require some logic (instead of a static html error page). – Pure.Krome Mar 18 '10 at 14:40
ecause the MVC model does not integrate with the IIS error page model. That simple. You ahve to go back to the IIS model for that. Register a page URL for the 404 case. Put some dynamic page there - I am not sure whether this actually COULD point back to a MVC url, but it MUSt originate in the 404 page registration. – TomTom Mar 18 '10 at 14:55
Incorrect. Most browsers will render the content of a page returned with a 404 HTTP status. Not all, but most. Also, IIS by default will respect the status code as set by any code in a .NET site, as long as no other modules are overriding that later in the pipeline. See the question author's answer on how that was happening in this case. – Mufasa Mar 19 '10 at 22:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.