multiple login page for forms authenticationhttp://forums.asp.net/t/1348477.aspx/1?multiple+login+page+for+forms+authenticationWed, 26 Nov 2008 15:26:51 -050013484772747089http://forums.asp.net/p/1348477/2747089.aspx/1?multiple+login+page+for+forms+authenticationmultiple login page for forms authentication <p>Hi,</p> <p>&nbsp;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.</p> <p>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 ? </p> <p>&nbsp;Thanks,</p> 2008-11-15T00:55:44-05:002747162http://forums.asp.net/p/1348477/2747162.aspx/1?Re+multiple+login+page+for+forms+authenticationRe: multiple login page for forms authentication <p>I have done this concept using single login form..</p> <p>check out htis url:</p> <p><a href="http://www.codeproject.com/KB/web-security/FormAuthenticnAuthorizn.aspx">http://www.codeproject.com/KB/web-security/FormAuthenticnAuthorizn.aspx</a></p> <p>&nbsp;</p> <p>&nbsp;</p> <p><a href="http://www.codeproject.com/KB/web-security/formsroleauth.aspx">http://www.codeproject.com/KB/web-security/formsroleauth.aspx</a></p> <p>&nbsp;</p> <p>i have not tried ur concept yet..surely can be done..</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> 2008-11-15T03:06:12-05:002747412http://forums.asp.net/p/1348477/2747412.aspx/1?Re+multiple+login+page+for+forms+authenticationRe: multiple login page for forms authentication <p>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 </p> 2008-11-15T07:36:51-05:002747756http://forums.asp.net/p/1348477/2747756.aspx/1?Re+multiple+login+page+for+forms+authenticationRe: multiple login page for forms authentication <p>Please explain abit better</p> 2008-11-15T13:13:56-05:002747862http://forums.asp.net/p/1348477/2747862.aspx/1?Re+multiple+login+page+for+forms+authenticationRe: multiple login page for forms authentication <p>&nbsp;Hi,</p> <p>Did you try putting two web.config files in two different folders with two different forms authentication settings..&nbsp;</p> 2008-11-15T14:52:00-05:002754379http://forums.asp.net/p/1348477/2754379.aspx/1?Re+multiple+login+page+for+forms+authenticationRe: multiple login page for forms authentication <p>Hi <strong>savagerider,</strong></p> <p>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 &quot;http:\\www.xx.com\Admin\Info.aspx&quot;, you could display the Login page in Admin directory. Here're the steps:</p> <p>1. Use a <strong>general Login page</strong> in the root of the web site - actually, you can&nbsp;put nothing in this Login page, it's just a middle page. In the <strong>Page_Load</strong> event, you have to parse the requested URL. Based on the requested URL, you can know which Login page&nbsp;should be&nbsp;redirected to. For instance:</p> <blockquote><pre class="prettyprint">protected void Page_Load(object sender, EventArgs e) { char[] chs = {'/'}; string[] strs = Request[&quot;ReturnUrl&quot;].Split(chs); if (strs[1] == &quot;Admin&quot;) { Response.Redirect(@&quot;\Admin\Login.aspx&quot;); } else if(strs[1] == &quot;Users&quot;) { Response.Redirect(@&quot;\Users\Login.aspx&quot;); } }</pre></BLOCKQUOTE> <P>2.&nbsp;In order to&nbsp;redirect to&nbsp;the two Login pages, you should&nbsp;set <STRONG>Location</STRONG> in the <STRONG>two</STRONG>&nbsp;<STRONG>subdirectories</STRONG> to allow anonymous access. For instance:</P> <BLOCKQUOTE><pre class="prettyprint">&lt;<SPAN class=tag><FONT color=#800000>configuration</FONT></SPAN>&gt; &lt;<SPAN class=tag><FONT color=#800000>location</FONT></SPAN><SPAN class=attr><FONT color=#ff0000> path=</FONT></SPAN><SPAN class=attrv><FONT color=#0000ff>"Login.aspx"</FONT></SPAN>&gt; &lt;<SPAN class=tag><FONT color=#800000>system.web</FONT></SPAN>&gt; &lt;<SPAN class=tag><FONT color=#800000>authorization</FONT></SPAN>&gt; &lt;<SPAN class=tag><FONT color=#800000>allow</FONT></SPAN><SPAN class=attr><FONT color=#ff0000> users=</FONT></SPAN><SPAN class=attrv><FONT color=#0000ff>"?"</FONT></SPAN>/&gt; &lt;/<SPAN class=tag><FONT color=#800000>authorization</FONT></SPAN>&gt; &lt;/<SPAN class=tag><FONT color=#800000>system.web</FONT></SPAN>&gt; &lt;/<SPAN class=tag><FONT color=#800000>location</FONT></SPAN>&gt; &lt;/<SPAN class=tag><FONT color=#800000>configuration</FONT></SPAN>&gt;</pre></blockquote> <p>Thanks.&nbsp; </p> 2008-11-19T06:09:03-05:002761617http://forums.asp.net/p/1348477/2761617.aspx/1?Re+multiple+login+page+for+forms+authenticationRe: multiple login page for forms authentication <p>Hi WenCui,</p> <p>&nbsp;This is <strong><u>EXACTLY</u></strong> what I'm looking for. Many thanks for your helps !!!!!</p> 2008-11-22T07:46:06-05:002769726http://forums.asp.net/p/1348477/2769726.aspx/1?Re+multiple+login+page+for+forms+authenticationRe: multiple login page for forms authentication 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, 2008-11-26T15:15:10-05:002769750http://forums.asp.net/p/1348477/2769750.aspx/1?Re+multiple+login+page+for+forms+authenticationRe: multiple login page for forms authentication <p>make sure to allow access to anonymous users to<strong> both of your Login.aspx</strong> pages</p> 2008-11-26T15:26:51-05:00