locked
Help on 404 custom RRS feed

  • Question

  • User-1778760930 posted

    "Create a web page (Err404.aspx) with custom error message which will be displayed when a user try to access a non-existing web page"

    I created the ERR404.aspx page, now this is code when i add to be web.config file

    <configuration>
    <appSettings/>
    <connectionStrings/>
    <system.web>
    <compilation debug="true" />

    <!-- Turn on Custom Errors -->
    <customErrors mode="On"
    defaultRedirect="/nonexistingpage.aspx">
    <error statusCode="404" redirect="/Err404.aspx"/>
    </customErrors>

    </system.web>
    </configuration>

    Now my end state is to basically test the configuration when the non existing webpage by typing https://localhost/nonexistingpage.aspx

    I would appreciate any help on this issues please.

    Rickyjj

    Monday, May 1, 2017 12:56 AM

Answers

  • User1168443798 posted

    What is your issue? What is your project type? Based on your description, it seems to be WebForm.

    I made a test with WebForm by following below steps, it works correctly.

    1. Add two pages DefaultRedirectErrorPage.aspx and Http404ErrorPage.aspx under Project Folder.

    2. Add below configuration.

      <customErrors mode="On"
            defaultRedirect="/DefaultRedirectErrorPage.aspx">
          <error statusCode="404" redirect="/Http404ErrorPage.aspx"/>
        </customErrors>

    3. Access http://localhost:2551/DefaultRedirectErrorPage.aspx, it shows DefaultRedirectErrorPage.aspx page

    4. Access http://localhost:2551/test.aspx which is not exist, it shows Http404ErrorPage.aspx.

    It would be helpful if you could share us detailed steps to reproduce your issue.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 1, 2017 3:04 AM