Recently I made a forum answer post to how you can redirect to a customised error page in ASP NET MVC 2 for error pages?
Here is the answer: -
<customErrorsmode="On"defaultRedirect="CustomErrorView" >
<errorstatusCode="404"redirect="Error/Error404" />
<errorstatusCode="500"redirect="Error/Error500" />
< /customErrors>
The controller:
public class ErrorController : Controller
{
// Return the 404 not found page
public ActionResult Error404()
{
return View();
}
// Return the 500 not found page
public ActionResult Error500()
{
return View();
}
}
This could be done with a static page if needed:
<customErrorsmode="On" >
<errorstatusCode="404"redirect="Static404.html" />
< /customErrors>
The link to the forum post is http://forums.asp.net/t/1693685.aspx/1?How+to+redirect+to+error+page+in+view+
No comments:
Post a Comment