Is it possible to have multiple login pages for different folders within an asp.net application? Say I have this structure:
/admin
/customer
/login-admin.aspx
/login-customer.aspx
I have 2 different login forms. One for the admin people and one for the customers (the forms are different as the customers need to provide extra information on their login page).
In the authentication section of the webconfig file (which is at the root of the web app), I can only specify one Login page. So how can I make sure that if anyone tries to access a webpage in /admin
they will be redirected to /login-admin.aspx
and if they try to access a webpage in /customer they will be redirected to /login-customer.aspx
?
Tha开发者_如何转开发nks,
Anthony
Unfortunately Forms Authentication only allows you to specify one login page.
While it's not the most elegant solution in the world, the login page could look at Request.QueryString["RedirectUrl"]
and use that to determine what to show users:
if(Request.QueryString["RedirectUrl"].ToUpperInvariant().Contains("/ADMIN"))
{
// Show an admin user control or transfer to another page
}
else
{
// Do something else
}
精彩评论