Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect from mastpage

Status
Not open for further replies.

tomouse

Technical User
Aug 30, 2010
50
Hello,

I have code on the page_init method of my masterpage that picks up the name of the logged in user and checks that this user is stored in the database. If the user isn't found in the database I want to display the content page "UnknownUser.aspx".

However, redirecting to this page (using Response.redirect("pagename.aspx") causes the page init of the masterpage to fire again, which checks the logged in user and redirects to the content page again, thus creating an infinite loop. What is the best way to prevent this? Should I move this code to some other location? Or is there a way to prevent the content page firing the masterpage init event?
 
I would use the authentication/authorization that is built into asp.net, rather than roll my own. there are various options and numerous examples on the web about configuring both authentication and authorization.

you example sounds like forms authentication with authorization being allow for known users and deny for unknown users.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top