Request_Begin

A

Amir Ghezelbash

Hi every one i want to make sure that my users are always loged in
before doing any thing in any of my wepages

i have added this code to my golab.asax but it loops indefintly ..any
one know why..and how can i stop it for looping?

void Application_BeginRequest(Object sender, EventArgs E) {
if (Customer.Current == null) {
Response.Redirect("Login.aspx");

}

my Customer class is just a wrapper of MemberShipUser class

it returns a correct value i have check it ..but this keeps looping
meaning Login page never loads i understand why ...its becuase when
loging page is called it runs this method and it tells it to load it
again becuase user didnt have a chance to login and Customer is still
null ..but how can i stop this?
 
K

Karl Seguin

Well, first off, you could use FormsAuthentication to do this for you. It
would automatically protect the pages you ask it to, and not the ones you
don't (automatically including the login page).

If you want to do it this way though, you'll need to chekc Request.Url and
make sure it isn't the login page.

if (Customer.Current == null && Request.Url.AbsoluteUrl != "xxx"){
redirect
}

Karl
 

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

Top