How to redirect from global.asax

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

When my web application starts I want to create some instances, if an
exception is raisen I want to show a specific page instead of the main page.
How can I transfer the execution to a new page?

using Server.Transfer doesn't work cause I don't have a page yet.

Thanks in advance
 
Hi,
Handle the application error in the Application_Error event.
Add the following code
this.Context.Response.Write(@"<script language='javascript'>window.parent.location.href = '" + <Page to redirect> + "'</script>");

Regards,

Sambath
 
I use System.Web.HttpContext.Current.Response.Redirect("new page.aspx" );

bill
 
The Request and Response objects are not available in the
Application_OnStart. So, I'm not sure who you would "show a specific page"
TO. I'm thinking that maybe you want to use Session_OnStart instead.
However, be aware that this will run every time a new user Session starts
(every time a new user logs into your app).

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
Back
Top