ASP. NET authentication (Update)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.