Configuration of ASP. NET 2.0 authentication items

Source: Internet
Author: User
Tags connectionstrings

In ASP. in net2.0, if the root directory allows anonymous users to access a page under the root directory (such as info. aspx) must be logged on (assuming the logon page is login. the web. the config file must be configured as follows:

<? XML version = "1.0"?>

<Configuration>
<Deleetask>
</Appsettings>
<Connectionstrings>
</Connectionstrings>

<System. Web>
<Compilation DEBUG = "true"/>

<! -- <Authentication mode = "Windows"/> -->
<Authentication mode = "forms">
<Forms loginurl = "login. aspx" Protection = "all" Path = "/" timeout = "30"/>
</Authentication>

<Authorization>

<! -- Anonymous allowed -->
<Allow users = "? "/>

</Authorization>

</System. Web>

<Location Path = "info. aspx">
<System. Web>

<! -- Authentication item configuration (when authentication information is specified for a separate page, the authentication section can only inherit from this directory, and cannot be set separately) -->
<! --
<Authentication mode = "forms">
<Forms name = ".www.cnpp.info" loginurl = "login. aspx" Protection = "all" Path = "/" timeout = "30"/>
</Authentication>
-->

<! -- User access control -->
<Authorization>

<! -- Block Anonymous -->
<Deny users = "? "/>

</Authorization>
</System. Web>
</Location>


</Configuration>

 

That is, the authentication item cannot be configured in the configuration section of the page to be authenticated. The authentication item can only be configured in the root directory, info. aspx inherits from the root directory. otherwise, the following error occurs: "The Section registered as allowdefinition = 'machinetoapplication' outside the application level is incorrect. This error may occur if the virtual directory is not configured as an application in IIS"

Finally, it is verified that the <authentication> <form section can only appear at the root site or application site.

Related Article

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.