How to redirect from global.asax

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
 
S

Sambathraj

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
 
W

William F. Robertson, Jr.

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

bill
 
K

Kevin Spencer

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top