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 .....