There are four types of authentication, the most widely used is froms these days to do the project to use the configuration file, compare the MVC and ASP. NET Discovery or MVC to force (MVC is called filter also have four of course also to be in config with Configured in the file)
But it's convenient. You just need to add [Authorze] to the method before you allow anonymous user access.
I'm going to take a look at this ASP. ASP. NET identity Authentication
<system.web>//Add <authentication mode= "Forms" > <forms loginurl= "~/under the system.web node Registeredlogin/login.aspx " timeout=" 2880 "defaulturl=" ~/"></forms> //url represents the path to jump to 2880 indicates that the effective time is calculated by the minute //defaulturl refers to the page that you jump to when you are logged in correctly, without pointing to the page. Loginurl refers to the login page where the user is not logged in and jumps to. For example, now a customer does not log in to the management, it will jump to loginurl. If you go directly to the login, that is, no error occurred in the direct login, after the successful login you always have//a hint or jump to which page, the page can be set in Defaulturl. </authentication> <!--site Configuration-- < </system.web>
This is the configuration is not logged in will jump to the login page
Of course, that's not enough.
Also specify which pages must be logged in to enter
So I'm going to write a
<location path= "Userxinxi" >//path refers to user information and user information I put in a call Userxinxi <system.web> <authorization> <deny users= "?" /> //users= "?" Deny anonymous user access </authorization> </system.web> </location> <!--site Configuration 2end-->
It's going to be like this.
Of course, these are probably the first steps to make.
Because now even if your account password is correct, you still stop on this page
Login Page Introduction
That's not it.
Is this--"using System.Web.Security;
And then the login button to add the event
then enter
Formsauthentication.setauthcookie (User, false); User is the text box of the input account session["user" = user; Response.Redirect (".. /index.aspx ");
And then it's okay.
Okay, so this is the use of Froms authentication verification
ASP. NET authentication (Update)