Multiple Forms Authentication scenarios on the same website?

故事扮演 提交于 2019-12-08 09:31:29

问题


I will soon be starting on a new web project that consists of 2 main areas.

  • Forums / Community
  • Recruitment

Until now, I've always used straightforward Forms Authentication on my community websites, and that one method of authentication, with that one cookie/ticket has been used throughout the website (with varying roles per user also stored in the ticket). I haven't used the built in LogIn controls and instead have always just created my own login/registration form, and written the code to insert into (and authenticate against in the log-in scenario) my bespoke 'Users' table. So I've essentially just been utilizing the .IsAuthenticated() method (to determine if a user is logged in), referenced the UserData property in the ticket (to determine which roles the user belongs to), and set up the 'location' restrictions in the Web.config, so the log-in page is automatically shown for pages that require 'member access' etc.

With my new project, I will need user registration/login for the Forums/Community part of the website only. I then need an additional user registration/login for the Recruitment part of the website (not related in any way to the users that sign up/log in to the Forums/Community part of the site).

I was wondering if this possible, and if so, how to go about it?

The user registration/sign-in pages might look the same, but my underlying code would would create accounts/authenticate against different DB tables.


回答1:


You could to create two different classes which inherits from MembershipProvider, each one with your specific database logic and connection string.

BTW, creating two groups isn't enough for your scenario? Would be weird if I needed two different credentials to log in into two different areas from same website.



来源:https://stackoverflow.com/questions/5403698/multiple-forms-authentication-scenarios-on-the-same-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!