-------- Web. config -------------- <! -- Windows-based Identity authentication --> <configuration> <system. web> <authentication mode = "Windows"> </authentication> <authorization> <! -- Anyone except anonymous can --> <deny users = "? "/> <Allow users =" * "/> <! -- Authorization, except for the Test anonymous, everyone else can --> <deny users = "? "/> <Deny users =" Test "/> <allow users =" * "/> </authorization> <compilation debug =" true "targetFramework =" 4.0 "/> </system. web> </configuration> <! -- Froms-based Identity authentication --> <configuration> <system. web> <authentication mode = "Forms"> <! -- The page on which loginUrl is logged on (all users log on from this page to the website and are not allowed elsewhere) to encrypt the protection for cookies --> <forms loginUrl = "login. aspx "timeout =" 2880 "name =" aaa "protection =" Encryption "/> </authentication> <! -- Authorization --> <authorization> <deny users = "? "/> <Allow users =" * "/> </authorization> <compilation debug =" true "targetFramework =" 4.0 "/> </system. web> <! -- Images in the images folder can be accessed --> <location path = "images"> <system. web> <authorization> <allow users = "? "/> </Authorization> </system. web> </location> <! -- SubPages under the subpages folder can be accessed --> <location path = "subPages"> <system. web> <authorization> <allow users = "? "/> </Authorization> </system. web> </location> </configuration> ---------- registor. aspx ----------- <body> <form id = "form1" runat = "server"> <div> registration page ...... </Div> </form> </body> ----------- default1.aspx ---------- <body> <form id = "form1" runat = "server"> <div> default1 page ............ ...... </Div> </form> </body> --------------- Login. aspx -------------------- <body> <form id = "form1" runat = "server"> <div> <asp: TextBox ID = "TextBox1" runat = "server"> </asp: textBox> <asp: TextBox ID = "TextBox2" runat = "server"> </asp: TextBox> <asp: button ID = "Button1" runat = "server" Text = "Button" Xonclick = "button#click"/> <br/> www.2cto.com <br/> <asp: login ID = "LoginControl" runat = "server"> </asp: Login> </div> </form> </body> ------------ Login. aspx. cs ------------------------- protected void button#click (object sender, EventArgs e) {if (this. textBox1.Text = "admin" & this. textBox2.Text = "123") {// from authorization, FormsAuthentication. setAuthCookie (this. textBox1.Text, false );}}