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

  • SEARCH
  • Home
  • 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 6150025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:33:09+00:00 2026-05-23T19:33:09+00:00

I am trying to add custom error pages to my web application. So far

  • 0

I am trying to add custom error pages to my web application. So far I have added this to my web.config file under the element:

<customErrors mode="On" >
    <error statusCode="404" redirect="~/404.aspx"/>
    <error statusCode="500" redirect="~/500.aspx"/>
</customErrors>

This works fine for errors that .NET touches for example a url that contains the .aspx extension. However I also want custom errors to display for a url such as http://www.example.com/dasda

Currently when I request a page such as the above IIS 7.5 displays it’s own error message. I have added this under the element:

<httpErrors >
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" path="~/404.aspx" responseMode="ExecuteURL"  />
    <remove statusCode="500" subStatusCode="-1" />
    <error statusCode="500" path="~/500.aspx" responseMode="ExecuteURL" />
</httpErrors>

I thought that this would make IIS display a custom error page instead of it’s default ones but this doesn’t seem to be the case.

I am aware that I can set a custom error page in IIS itself but an ideal solution for my situation would be to have this configurable in the web.config.

I have tried adding this into my custom error pages on the Page_Load event as suggested here :

            Response.TrySkipIisCustomErrors = true;

However it did not stop the default IIS page from showing in place of my custom error page. I have also tried what is suggested here:

<httpErrors >
    <remove statusCode="404" subStatusCode='-1' />
    <error statusCode="404" path="~/404.aspx" prefixLanguageFilePath='' responseMode="Redirect"  />
    <remove statusCode="500" subStatusCode='-1' />
    <error statusCode="500" path="~/500.aspx" prefixLanguageFilePath='' responseMode="Redirect" />
  </httpErrors>

But this has also not worked.

So is there a way to prevent IIS from displaying default error pages by configuring settings in the web.config file?

  • 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-23T19:33:10+00:00Added an answer on May 23, 2026 at 7:33 pm

    The problem I was encountering was that by default has an attribute errorMode with the following options: DetailedLocalOnly, Custom or Detailed.

    If the errorMode attribute is left unspecified as I was doing then it defaults to DetailedLocalOnly (ref). Which means I would not have seen the custom error that was displayed.

    The configuration settings that worked were:

    <httpErrors errorMode="Custom">
        <remove statusCode="404" subStatusCode='-1' />
        <remove statusCode="500" subStatusCode='-1' />
        <error statusCode="404" path="/404.aspx" prefixLanguageFilePath="" responseMode="ExecuteURL"  />
        <error statusCode="500" path="/500.aspx" prefixLanguageFilePath="" responseMode="ExecuteURL" />
      </httpErrors>
    

    The errorMode=”Custom” is handy to test the custom pages are working correctly but is probably more handy when left omitted or set explicitly to errorMode=”DetailedLocalOnly” for debugging purposes.

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

Sidebar

Related Questions

Have had no luck trying to add a reference to a custom.css file to
I'm trying to add a custom font as a resource in my application. I
I'm trying add a tab to my web page that looks like this: Using
I'm trying to get custom HttpHandler working in my sample web application. I've been
I'm trying to dynamically add elements to an accordion. Each added element contains a
I have a C# ASP.NET web application an I am trying to populate an
I'm trying to have an asp.net custom control with a field like: <ErrorTemplate> <h1>Error</h1>
I was trying to make a custom application form. I've added some control like
I am trying to add some custom build steps to my headless build process
I'm trying to add a custom property which is a guid, but it gives

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.