Add a security mechanism for the website. Verify the security mechanism for windows and Form.

Source: Internet
Author: User

-------- 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 );}}

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.