Security authentication and web.config configuration of asp.net
Source: Internet
Author: User
asp.net|web| Security (1) in Web.config configuration
Modify options in <system.web>
The validation mode is set to form and the validation page is
<authentication mode= "Forms" >
<forms loginurl= "Login.aspx"/>
</authentication>
Do not allow anonymous users
<authorization>
<deny users= "?"/>
</authorization>
After </system.web> add a page that does not validate to use the database to access the database on the page to see if the user exists.
<location path= "Reg.aspx" >
<system.web>
<authorization>
<allow users= "*"/>
</authorization>
</system.web>
</location>
(2) in the code in the normal way, such as asking the other party to enter information to find the database or XML validation, after verification, the execution of this sentence will be validated by the same jump will begin to enter the page
System.Web.Security.FormsAuthentication.RedirectFromLoginPage (username,true);
Cancellation with System.Web.Security.FormsAuthentication.SignOut ();
If you do not want to jump back, you can first authorize and redirect to other pages System.Web.Security.FormsAuthentication.SetAuthCookie ();
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