IIS is overriding my response content, if i manually set the Response.StatusCode
- by Pure.Krome
Hi Folks,
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. Casinni), it works correctly (ie. my content is displayed and the response.statuscode == my entered data.
Is there anyway I can override this behaviour?
How To Replicate
Make a default ASP.NET MVC1 web app.
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();
}
}
:( Please help!