Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 852073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:32:03+00:00 2026-05-15T07:32:03+00:00

I am trying to use custom error pages using redirects in IIS7. This is

  • 0

I am trying to use custom error pages using redirects in IIS7. This is my code:

<httpErrors>
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" prefixLanguageFilePath="" path="/Pages/NotFound" responseMode="ExecuteURL" />
</httpErrors>

As you can see the line <remove statusCode="404" subStatusCode="-1" /> resets the status code and when I hit the page I get a Status Code of 200 for a page that is not found. Is that really the right way to handle pages that are not found?

My understanding is that I would want to return 404 errors even when I show a nice page from within my site for pages that don’t exist. I know this is an edge case but I am trying to cover all of my bases.

the page I am redirecting to is an .aspx page and has c# code behind it. In the page I am putting:

protected void Page_Load(object sender, EventArgs e)
        {
            Response.Status = "404 Not Found";
        } 

This code does not appear to actually do anything though. Does anyone have any guidance on if I should be returning 404 Errors and if so how to do it? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:32:03+00:00Added an answer on May 15, 2026 at 7:32 am

    When you do a redirect for a page not found error, it is essentially exception handling by the web server. You will get a 200 response, but just a nice page saying – “Hi, what you are looking for is not here.” Without a redirect/custom error page, the browser is left up to its own devices to see the 404 and display some type of error to the end user. The 404 error could be logged in this instance as the error had to occur to get the redirect. You shouldn’t need to change your response codes unless you have a reason to (i.e., unauthorized content request you may want to return a 404 instead of saying unauthorized).

    As for your code, it should read this:

    Response.StatusCode = 404;
    

    However, if you send a 404 error out on your custom 404 error page, if you will get in some crazy loop in IIS. 404 -> Custom Error Page (returns 404) -> Custom Error Page (returns 404) -> etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use custom container widgets in gtk.Builder definition files. As far as
I'm trying to use a custom configuration section, something I've done numerous times before
I'm trying to use multiple attributes in my custom tag, e.g.: <mytaglib:mytag firstname=Thadeus lastname=Jones
I'm building a custom web part for SharePoint and I'm trying to use the
I'm trying to serialize a custom class that needs to use multiple elements of
I am trying to use ELMAH for my error logging, and I've tried several
I'm trying to use the AspNetCompiler task within a custom msbuild file to precompile
Trying to use an excpetion class which could provide location reference for XML parsing,
Trying to use a guid as a resource id in a rest url but
While trying to use LINQ to SQL I encountered several problems. I have table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.