Asp.net Forms Verification

Source: Internet
Author: User

I personally think that Forms authentication is better used in the background to prevent some illegal users from entering the background.

Forms can only access other pages after a user logs on to the page and saves the Cookie.

To verify Forms, copy the following code to the web. config file on the page.

<Authentication mode = "Forms">

<! -- Set the verification attribute loginUrl = "Logon page" -->


<Forms name = "forums" path = "/" timeout = "40" protection = "All" loginUrl = "Login. aspx"/> <! -- Login. aspx is your logon page -->
</Authentication>
<Authorization>

<! -- Set the resource to be protected and anonymous users are not allowed to access it -->


<Deny users = "? "/>
</Authorization>

<System. web> copy the code to the middle of this sentence! </System. web>

Copy this code to the configuration file and go to Login. aspx (logon page) to check whether the user name is correct. If yes, add the following in the correct code:

FormsAuthentication. SetAuthCookie (user, false );

This code can access other pages in the background.

If this is the case, if Login. the aspx page calls the css style of other files, or applies the image images of other folders, so that Login. the called css and image files are not displayed on the aspx page. How can this problem be solved? There is no way to remove some folders or files from the following code ....

<Location path = "here is the path to unsecure folders or files! ">
<System. web>
<Authorization>
<Allow users = "? "/>
</Authorization>
</System. web>
</Location>

 

In this way, you can access other files without the limitations of Forms.

Complete code: Configuration

<Configuration>
<System. web>
<Compilation debug = "true" targetFramework = "4.0"/>
<Authentication mode = "Forms">
<Forms name = "forums" path = "/" timeout = "40" protection = "All" loginUrl = "Login. aspx"/>
 
</Authentication>
<Authorization>
<Deny users = "? "/>
</Authorization>
</System. web>
<! ---------------- Unprotected exception file ---------------------->
<Location path = "App_Themes">
<System. web>
<Authorization>
<Allow users = "? "/>
</Authorization>
</System. web>
</Location>

</Configuration>

 

Background:

FormsAuthentication. SetAuthCookie (user, false );

If the user name is added ..

If you have any errors or incorrect understanding, please forgive me. Leave a message .....

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.