Problem
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)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{*catchall}",
new { controller = "Home", action = "Index" }
);
}
Now replace the the HomeController's Index method with...
[HandleError]
public class HomeController : Controller
{
public ActionResult Index()
{
Response.StatusCode = 404;
return View();
}
}