ASP. NET security issues--froms validation of the specific introduction (medium)

Source: Internet
Author: User
Keywords We authenticate nbsp;
Tags asp authenticate authentication client configure cookie cookies file

Enable Forms authentication

I'm sure you know very well how to enable forms validation, but here I'm just a little wordy. All we need to do is configure the following in the Web.config file:

<authentication mode= "Forms"/>

After that, the ASP. NET runtime knows that we have enabled forms validation and that the FormsAuthenticationModule module is activated during the verification phase of the lifecycle. It's also important to note that the:<authentication/> element node can only be configured in Web.config in the application's root folder. If you use this node in a subfolder, you will get an error. This also shows that each application can define only one authentication type.

And in the <authentication/> node, we can also make more settings. Follows:

<authentication mode= "Forms" >
<forms name= "MyCookie"
Loginurl= "Login.aspx"
timeout= "60"
Path= "/"
protection= "All" >
</forms>
</authentication>

Let's look at the meaning and purpose of the attributes in the <forms> node:

Name: Defines the names of the authentication cookies. Because we put the authenticated ticket in a cookie, we have to give the authentication cookie a unique name to prevent conflicts with cookies in other applications.

Loginurl: You can tell from the English name about the login. It actually indicates which page to redirect the user to to login.

Timeout: Sets the duration, in minutes, of the authentication cookie. And this time is a relative time, which means that each time the user is authenticated, the cookie's duration is reset. If the user does not initiate a request to the server within 60 minutes, the cookie expires, and then if the user initiates the request again, the user name and password will be re-enter.

Path: Set the path of the cookie's save, generally set to "/", we do not easily change.

As we have said before, our authenticated ticket is encrypted and then stored as a cookie, and then the cookie is sent to the client. When the client requests again, the server side will resolve the cookie information sent by the client, we must confirm: The client sent the cookie information we sent from the server before the past, that is, we have to determine whether our cookies in the client has been tampered with.

So, this is the purpose of the attribute homeowner in <forms/>. Homeowner has four values:

Encryption: Encrypts the content information of the cookie.
Validation: Adds a MAC (message authentication code) to the contents of the cookie so the server can determine if the cookie has been tampered with.
None: Disabling encryption and tampering checks
All: Enable both encryption and tamper checking.
By default, "All" because it can encrypt data into a cookie and authenticate cookies that are returned to the server side.

Continue >> Next [1th] [page 2nd] [3rd]

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: info-contact@alibabacloud.com 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.