In my web.config
file I have custom errors enabled:
<customErrors mode="On" defaultRedirect="~/Error">
<error redirect="~/Error/NotFound" statusCode="404" />
</customErrors>
My NotFound
action:
public ActionResult NotFound()
{
Response.StatusCode = 404; //no issues when this is not set
return View();
}
The problem:
This configuration works fine on a local server, but when I move it to a remote server custom 404 pages are not shown (IIS default 404 is displayed) unless the status code of NotFound
action is set to 200.
Could someone explain what's going on?