I'd like to show a different 404 page for a specific controller then using the default I have now. How can I do this? Here is my setup now:
protected void Application_Error()
{
if (!Request.IsLocal)
{
var context = new HttpContextWrapper(HttpContext.Current);
if (!context.Request.IsAjaxRequest())
{
context.Response.ContentType = "text/html";
var unhandledException = Server.GetLastError();
var httpException = unhandledException as HttpException;
if (httpException == null)
{
var innerException = unhandledException.InnerException;
httpException = innerException as HttpException;
}
Server.ClearError();
var routeData = new RouteData();
routeData.Values.Add("controller", MVC.Errors.Name);
if (httpException != null)
{
var httpCode = httpException.GetHttpCode();
switch (httpCode)
{
case (int) HttpStatusCode.NotFound:
routeData.Values.Add("action", "PageNotFound");
IController pageNotFoundController = new ErrorsController();
pageNotFoundController.Execute(new RequestContext(context, routeData));
break;
}
}
else
{
routeData.Values.Add("exception", unhandledException);
routeData.Values.Add("action", "Error");
IController errorController = new ErrorsController();
errorController.Execute(new RequestContext(context, routeData));
}
}
}
}