ÎªÍøÕ¾Ìí¼Ó°²È«»úÖÆ£¬windowsÓëFormÑéÖ¤
3427 µã»÷¡¤0 »ØÌû
![]() | ![]() | |
![]() | --------web.config-------------- <!--»ùÓÚWindowsµÄÉí·ÝÈÏÖ¤--> <configuration> <system.web> <authentication mode="Windows"></authentication> <authorization> <!--³ýÁËÄäÃûÖ®Íâ±ðÈ˶¼¿ÉÒÔ--> <deny users="?"/> <allow users="*"/> <!-- ÊÚȨ£¬³ýÁËTestÕâ¸öÄäÃû£¬±ðÈ˶¼¿ÉÒÔ--> <deny users="?"/> <deny users="Test"/> <allow users="*"/> </authorization> <compilation debug="true" targetFramework="4.0" /> </system.web> </configuration> <!--»ùÓÚFromsµÄÉí·ÝÈÏÖ¤--> <configuration> <system.web> <authentication mode="Forms"> <!--loginUrlµÇ¼ʱµÄÄǸöÒ³Ãæ£¨ËùÓеÄÓû§¶¼´ÓµÇ¼Õâ¸öÒ³Ãæ½øÈëÍøÕ¾£¬±ðµÄµØ·½²»Èýø£© ¸øCookie¼ÓÃÜprotection --> <forms loginUrl="login.aspx" timeout="2880" name="aaa" protection="Encryption"/> </authentication> <!--ÊÚȨ--> <authorization> <deny users="?"/> <allow users="*"/> </authorization> <compilation debug="true" targetFramework="4.0" /> </system.web> <!--ÔÚimagesÎļþ¼ÐϵÄͼƬÊÇ¿ÉÒÔ±»·ÃÎʵÄ--> <location path="images"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location> <!--ÔÚsubPagesÎļþ¼ÐϵÄ×ÓÒ³ÊÇ¿ÉÒÔ±»·ÃÎʵÄ--> <location path="subpages"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location> </configuration> ----------registor.aspx----------- <body> <form id="form1" runat="server"> <div> ×¢²áÒ³¡¡ </div> </form> </body> -----------default1.aspx------------ <body> <form id="form1" runat="server"> <div> default1Ò³¡¡¡¡¡¡ </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="Button1_Click" /> <br /> <br /> <img src="images/1.gif" /> www.atcpu.com <br /> <asp:Login ID="LoginControl" runat="server"> </asp:Login> </div> </form> </body> --------------Login.aspx.cs----------------------- protected void Button1_Click(object sender, EventArgs e) { if (this.TextBox1.Text == "admin" ;; this.TextBox2.Text == "123") { //fromÊÚȨ£¬ FormsAuthentication.SetAuthCookie(this.TextBox1.Text, false); } } | |
![]() | ![]() |