Beispiel #1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string uname = Login1.UserName.ToString();
            string pass  = Login1.Password.ToString();

            if (Membership.ValidateUser(uname, pass))
            {
                aspnet_UsersDomainModel aspUser = aspUserBLL.ListAspUser(uname.Trim());
                Session["UserID_GUID"] = aspUser.UserId;

                if (Request.QueryString["ReturnUrl"] != null)
                {
                    FormsAuthentication.RedirectFromLoginPage(uname, false);
                }
                else
                {
                    FormsAuthentication.SetAuthCookie(uname, false);
                    Response.Redirect("~/Default.aspx");
                }
            }
            else
            {
                Response.Write("Invalid Login");
            }
        }
Beispiel #2
0
        private void GetFormsAuthCookie()
        {
            HttpCookie authCookie            = Request.Cookies[FormsAuthentication.FormsCookieName];
            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);

            if (ticket != null)
            {
                string strUserName = ticket.Name;
                aspnet_UsersDomainModel aspUser = aspUserBLL.ListAspUser(strUserName.Trim());
                Session["UserID_GUID"] = aspUser.UserId;
            }
        }