开发者

Form Authentication w/ multiple login pages

I have read the many posts of people trying to use two different login pages: one for users and one for admins. My question is very different. I have a Site.master page with a LoginView and LoginControl. I then have three root level pages Default.aspx, About.aspx, and Contact.aspx that derive from the Site.master. All three pages are set in the web.config to be allowed to all users. I then have a MemberPage in a Member folder which is only accessible to authenticated users. What I want to have happen is to be able to login from either the Default, About, or Contact pages and then be directed to the MemberPage.

The way Form Authentication is set now, I can only have one loginUrl and one defaultUrl. Which means if I have this settings in my web.config:

<authentication mode="Forms"> <forms name="ishAuth" loginUrl="Default.aspx" timeout="50" defaultUrl="~/Member/MemberPage.aspx"></forms> </authentication>

the only page that redirects to the /Member/MemberPage.aspx is the Default.aspx. I want my users to be able to browse through the anonymous section of the site and login from any page and then be redirected to the MemberPage. Right now if I am on the About.aspx page and log in I am authenticated but remain on the开发者_C百科 About page.

Is there a way around the properties of the element? Can I turn off the default actions of the element and do the redirect using my own custom code?


I don't have access to Visual studio right now, but you should be able to use the "OnLoggedIn" event of the login control to do what you want. Create the even handler for that event, and simply just put Response.Redirect("~/Member/MemberPage.aspx") and your users should get redirected to the right page.

You can have a look at this page on the MSDN for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜