Auto-redirect in Application_Beginrequest?

G

Guest

In certain situations I'd like to prevent users from accessing my
default.aspx page and automatically redirect them to an alternative page.

Would it be feasible to do this in Application_Beginrequest in global.asax,
or is there a better way.

This functionality needs to be configured on a per-session basis.
 
B

Brock Allen

You should not do it in Application_BeginRequest if you reply upon Session
because Session has not yet been loaded and made avaialable at that point.
Instead you should do it in Application_PreRequestHandlerExecute.
 
G

Guest

Hi Brock,

Thanks for your response. Hope you had a nice xmas.

How would I go about doing this? Should I just use standard
Response.Redirect()?

ie:

if (Request.RawUrl.ToUpper().IndexOf("DEFAULT.ASPX") > -1) {
Response.Redirect("otherdefault.aspx");
}

Thanks

Ben
 
B

Brock Allen

That will work. When you said above you rely upon session, you're talking
about session state?
 

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

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,155
Latest member
JuliW73391
Top