2

I'm running a ASP.Net 4 site on Windows 2008 R2 with IIS 7.5.

When developing I use windows 7 and VS 2010 with IIS 7.5 as well.

I've setup my web.config as such:

<customErrors mode="On" defaultRedirect="~/Error500.aspx" redirectMode="ResponseRewrite">
  <error statusCode="404" redirect="~/Error404.aspx"/>
</customErrors>

And my Error404.aspx page has this in its code-behind:

protected void Page_Load(object sender, EventArgs e)
{
    Response.StatusCode = 404;
}

On my developer machine this works fine, I see my pretty errorpage in the browser, and using Fiddler I can confirm I only receive the 404 HTTP status.

Now when I publish it to my server, it's a different story. Here I'll see the IIS' own 404 page ("C:\inetpub\custerr\en-US\404.htm")

If I remove the Response.StatusCode in my code-behind, I get the errorpage fine on the server, albeit with a 200 HTTP status.

What am I overlooking since this doesn't work ?

1 Answer 1

2

Does this article by Rick Strahl help? It covers 500 errors and the TrySkipIisCustomErrors property to override the default IIS behaviour.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry for the late reply, I was reassigned to a different project temporarily. I'll check up on this tomorrow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.