I wonder if it is possible to have multiple login page for different folder within the web application. Assuming there are administrator login page and normal user login page. I understand that we can make use of the role to differentiate them, but given
the condition that administrator and user should see different login screen. An example will be a login.aspx in admin folder and login.aspx at the top level.
Does anyone has any idea how to do it ? Is this the limitation on forms authentication to only allow one login page in the entire asp.net ?
I think everyone tried single login form before. Apparently this seems to be the limitation in the asp.net forms authentication. Unless we do not use the formsAuthentication class
Kyle Isaacs
Email : kyle@live-it.com
Skype : kyle.isaacs01
______________________________________
Please do note "FORGET" to mark post as answer if its correct
Basically, you could only set one Login page in ASP.NET. However, if you want to display different Login pages to different users, you could achieve it indirectly. Since we don't know the role before the user login, we can take advantage of the request URL.
For example, if the user request "http:\\www.xx.com\Admin\Info.aspx", you could display the Login page in Admin directory. Here're the steps:
1. Use a general Login page in the root of the web site - actually, you can put nothing in this Login page, it's just a middle page. In the
Page_Load event, you have to parse the requested URL. Based on the requested URL, you can know which Login page should be redirected to. For instance:
Hi, After a few tries, i realize that the method will not work if form authentication is used. Apparently, we need to use the login Page as the middle that you mentioned above. In this case, if you tried to access page that is under Admin folder, it should
redirect to Admin\login.aspx, but at this stage because the page is not authenticated yet, then it will redirect to login page (the middle) page again. It will end up in a dead-lock situation. Pls advise on the implementation that you mentioned. Thanks,
savagerider
Member
82 Points
29 Posts
multiple login page for forms authentication
Nov 15, 2008 12:55 AM|LINK
Hi,
I wonder if it is possible to have multiple login page for different folder within the web application. Assuming there are administrator login page and normal user login page. I understand that we can make use of the role to differentiate them, but given the condition that administrator and user should see different login screen. An example will be a login.aspx in admin folder and login.aspx at the top level.
Does anyone has any idea how to do it ? Is this the limitation on forms authentication to only allow one login page in the entire asp.net ?
Thanks,
msn_senthil_...
Member
52 Points
16 Posts
Re: multiple login page for forms authentication
Nov 15, 2008 03:06 AM|LINK
I have done this concept using single login form..
check out htis url:
http://www.codeproject.com/KB/web-security/FormAuthenticnAuthorizn.aspx
http://www.codeproject.com/KB/web-security/formsroleauth.aspx
i have not tried ur concept yet..surely can be done..
savagerider
Member
82 Points
29 Posts
Re: multiple login page for forms authentication
Nov 15, 2008 07:36 AM|LINK
I think everyone tried single login form before. Apparently this seems to be the limitation in the asp.net forms authentication. Unless we do not use the formsAuthentication class
kyle@live-it...
Member
586 Points
217 Posts
Re: multiple login page for forms authentication
Nov 15, 2008 01:13 PM|LINK
Please explain abit better
Email : kyle@live-it.com
Skype : kyle.isaacs01
______________________________________
Please do note "FORGET" to mark post as answer if its correct
shashankgwl
All-Star
18926 Points
3662 Posts
Re: multiple login page for forms authentication
Nov 15, 2008 02:52 PM|LINK
Hi,
Did you try putting two web.config files in two different folders with two different forms authentication settings..
All is well if it runs well.
blog
Wencui Qian ...
All-Star
56784 Points
5796 Posts
Microsoft
Re: multiple login page for forms authentication
Nov 19, 2008 06:09 AM|LINK
Hi savagerider,
Basically, you could only set one Login page in ASP.NET. However, if you want to display different Login pages to different users, you could achieve it indirectly. Since we don't know the role before the user login, we can take advantage of the request URL. For example, if the user request "http:\\www.xx.com\Admin\Info.aspx", you could display the Login page in Admin directory. Here're the steps:
1. Use a general Login page in the root of the web site - actually, you can put nothing in this Login page, it's just a middle page. In the Page_Load event, you have to parse the requested URL. Based on the requested URL, you can know which Login page should be redirected to. For instance:
2. In order to redirect to the two Login pages, you should set Location in the two subdirectories to allow anonymous access. For instance:
Thanks.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
savagerider
Member
82 Points
29 Posts
Re: multiple login page for forms authentication
Nov 22, 2008 07:46 AM|LINK
Hi WenCui,
This is EXACTLY what I'm looking for. Many thanks for your helps !!!!!
savagerider
Member
82 Points
29 Posts
Re: multiple login page for forms authentication
Nov 26, 2008 03:15 PM|LINK
guru_sarkar
All-Star
22198 Points
3463 Posts
Re: multiple login page for forms authentication
Nov 26, 2008 03:26 PM|LINK
make sure to allow access to anonymous users to both of your Login.aspx pages