Skip to content

Instantly share code, notes, and snippets.

@jcreamer898
Last active January 2, 2016 18:09
Show Gist options
  • Save jcreamer898/8341711 to your computer and use it in GitHub Desktop.
Save jcreamer898/8341711 to your computer and use it in GitHub Desktop.
public ActionResult NotFound()
{
ActionResult result;
object model = Request.Url.PathAndQuery;
if (!Request.IsAjaxRequest())
{
result = View("NotFound", model);
}
else
{
result = PartialView("NotFound", model);
}
return result;
}
protected void Application_EndRequest()
{
if (Context.Response.StatusCode == 404)
{
Response.Clear();
var rd = new RouteData();
rd.Values["controller"] = "Errors";
rd.Values["action"] = "NotFound";
IController c = new ErrorController();
c.Execute(new RequestContext(new HttpContextWrapper(Context), rd));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment