Решение:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | В web.config: <authentication mode="Forms"> <forms loginUrl="Login.aspx"> <credentials> <user name="Joe" password="Smith" /> </credentials> </forms> </authentication> В форме: if (FormsAuthentication.Authenticate(this.txtLogin.Text, this.txtPass.Text)) { FormsAuthentication.SetAuthCookie(this.txtLogin.Text, false); FormsAuthentication.RedirectFromLoginPage(this.txtLogin.Text, false); } else { Response.Write("Invalid login details. Please try again."); } В защищенной странице: if (!Page.User.Identity.IsAuthenticated) Response.Redirect("/in.aspx"); |