404 Setting for a sub-application

Discussion in 'ASP.NET / ASP.NET Core' started by bebemau, Nov 6, 2003.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi all,

    I have set one of my subfolders as an application, so I have 2 applications under my account. I know I can use IIS manager in control panel to set the default redirect page for any 404 error. But that setting is for my root application only. So is there a way to set a 404 error default redirect for my sub-application(except in web.config)?

    Thanks in advance.
     
  2. You cannot configure a different CustomError page from your root web.config on DASP. However, you can get the same result by adding code to the Application_Error event in the global.asax.vb file of your sub web:

    Sub Application_Error(ByVal sender as Object, ByVal e as EventArgs)

    Response.Redirect("myErrorPage.aspx")

    End Sub

    Keith Payne
    Technical Marketing Solutions
     
  3. KPayne,

    Although web.config is not what I wanted to use to handle 404 errors, I gave it a try anyway, and it seems to be working properly.

    I assume what you are talking about is when you have an aspx application at the root with its own web.config, and at the same time you have another aspx sub-application in which has its own web.config also.

    My config is a little different, I have an asp application at the root, and I have an aspx application as the sub-web.

    But thats good info to know. Thanks!!
     
  4. Hi there,

    Thanks for the reply. You meant if I put this code in my webconfig under my subweb, it will not work?

    <customErrors mode="On">
    <error statusCode="404" redirect="404.aspx"/>
    </customErrors>
     
  5. Correct. The <system.web> section of the web.config - where the <customErrors> tag goes - will give an error if you have it in a subweb.

    Keith Payne
    Technical Marketing Solutions
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page