Use authentication forms Authentication Mode

Source: Internet
Author: User
Use authentication Forms authentication mode.
First, in the Application Program Configuration file (Web. config. The details are as follows:
Configure the authentication node to use the forms authentication mode. You can search for the nodes online.
<Authentication mode = "forms">
<Forms name = ". User" loginurl = "login. aspx" timeout = "1"/>
</Authentication>
Configure the authorization node to reject Anonymous Access
<Authorization>
<Deny users = "? "/>
</Authorization>
Then, you can connect to the database on the login. ASPX page to verify the user. The method I use is:
If (validatelogin (UID, PWD) // This method searches for records in the database based on the UID passed in, and returns true if any.
{
Formsauthentication. setauthcookie (UID, false );
// Set the cookie. You can also use redirectfromloginpage (UID, false) to directly go to the default page.
Response. Redirect ("index. aspx"); // redirect
}
In this way, if the user wants to access restricted resources without authentication, it will be directed to the login. ASPX page.

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.