ASP.NET Login page

2020-07-22 19:16发布

问题:

I want to add login for registered users in my website. How shall I proceed with it? Is it through the use of sessions? What will happen to the Session variable once the logout happens??

回答1:

Your question is extremely broad and there are many different ways that you can implement what is, in effect, a "membership" system for an ASP.NET website.

I would suggest that you start by reading the "Introduction to Membership" article from MSDN. This article will give you an overview of how ASP.NET membership works in the most "standard" way.

It also mentions using the various ASP.NET membership "controls" (Login, LoginView, LoginStatus & PasswordRecovery for example).

Using these controls along with the built-in ASP.NET membership providers (for example, ASP.NET provides a SQL membership provider to work against SQL Server as the data store for your user accounts and credentials) will allow you to implement a complete membership and authentication system with virtually no code at all (i.e. all the functionality is provided by the built-in "membership" controls and declarative mark-up).

Finally, a really good series of articles on this subject is:

Examining ASP.NET 2.0's Membership, Roles, and Profile

from the 4guysfromrolla site. It's starts at the very beginning of the membership topic and goes right the way through to touching on the implementation of a custom membership provider and administrative interface for managing user credentials to round out the whole subject.



回答2:

I'd take a look a related questions, such as

Login Membership .NET

This topic is already covered quite a lot on SO.

Session state and log in are somewhat orthogonal. You have a session regardless of whether or not you are logged in.



回答3:

You should use the provided Login control and Membership system.

About Session vars, nothing special will happen. ASP.NET forms authentication does not use SessionState by default.



回答4:

I would recommend using forms authentication with perhaps a custom backend using IIdentity and IPrincipal. There’s lots of information available how to do this but I think this link forms a good starting point http://msdn.microsoft.com/en-us/library/aa480476.aspx



标签: asp.net