I am trying to setup a custom 404 error page. In my web.config I have this in my system.web
<customErrors mode="RemoteOnly">
<error statusCode="404" redirect="~/Home/Error404" />
</customErrors>
I have this method in my HomeController
public ActionResult Error404()
{
return View();
}
and this my view
@{
ViewBag.Title = "Error404";
}
<h2>Error404</h2>
My problem is when I goto the URL that does not exist in my website, I do not get my custom page. Is there something I am missing?
The custom error pages are not enabled for local in your code. So, if you are testing this locally it will not work. Change the web.config entry as below to enable custom error pages locally as well
<customErrors mode="On">
<error statusCode="404" redirect="~/Home/Error404" />
</customErrors>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments