Authorization element tip

Source: Internet
Author: User

I saw a question today on the ASP. net Forum about the <authentication> element and decided to write something about it. most of you already know this but I still think there are some that don't know about what I'm going to write about.

 

If you are not familiar with the <authorization> element, read the following section:

 

The <authorization> element is located within the web. config File and can be used to give users or roles authorization to enter the site. with the authorization section you can both deny and allow users or roles to visit your site. by default all users have authorization to visit the site.

 

Take a look at the following two examples:

 

Example 1:

 

<Authorization>

<Allow user = "XXX, yyy"/>

<Deny users = "*"/>

</Authorization>

 

Example 2:

 

<Authorization>

<Deny users = "*"/>

<Allow user = "XXX, yyy"/>

</Authorization>

 

As you can see the two examples abve do the same thing, they allow user XXX and YYY to enter the site and deny all users to enter the site. But is there any different between the two examples? Yes it is. the important thing to know here is that ASP. net will start at the head of the list and checks the rules until the first match is found, so if the first element is deny all users, all users will be denied access even if some users is allowed to enter the site by adding the allow as the second rule (see example 2 ). but if the allow is added first and the authenticated user is one of the specified, they will be granted access even if you have denied all users as the second rule in the list (SE Example 1 ). so have this in mind when you use the <authorization> element.

Http://fredrik.nsquared2.com/viewpost.aspx? Postid = 352

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.