コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Control controlMenu = Page.Master.FindControl("NavigationMenu");

            if (controlMenu != null)
            {
                controlMenu.Visible = false;
            }
            if (IsPostBack)
            {
                if (BLL.GetUserAuthentication(useridtextbox.Text, passwordtextbox.Text))
                {
                    //Response.Redirect("/UI/Products.aspx");
                    //FormsAuthentication.RedirectFromLoginPage(useridtextbox.Text, rememberCheckbox.Checked);

                    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                                                                                     useridtextbox.Text,
                                                                                     DateTime.Now,
                                                                                     DateTime.Now.AddMinutes(60),
                                                                                     rememberCheckbox.Checked,
                                                                                     "UserData",
                                                                                     FormsAuthentication.FormsCookiePath);

                    string encryptedTicket = FormsAuthentication.Encrypt(ticket);

                    Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket));

                    Response.Redirect(FormsAuthentication.GetRedirectUrl(useridtextbox.Text, rememberCheckbox.Checked));
                }
                else
                {
                    errorlbl.Visible = true;
                }
            }
        }