views:

238

answers:

2

In a regular ASP.NET application, you might have a customErrors section like the following:

<customErrors mode="On">
  <error statusCode="404" redirect="Nice-FileNotFound-Page.aspx"/>
</customErrors>

Is it possible to set the 404 error programmatically at Application_Start? Something like the following:

// Figure out which page should be used... using some logic somewhere in the application
// (obviously) Pseudo-code: Application.ErrorCode.404.Page = Page-Found-Above
+2  A: 

You can put that logic in Nice-FileNotFound-Page.aspx and redirect from there to the appropriate page using any business logic you need.

pgb
A: 

This is not asp specific, but as long as "Nice-FileNotFound-Page.aspx" is a dynamic script, couldnt you just make is be whatever you want it to be? That is to say, let it figure out programatically what kind of page it is supposed to be based on the logic and then be that page?

Shane C. Mason