Click here to Skip to main content
15,940,271 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am making custome login management system... using FormAuthentication Ticket

i made login page in a custome way and in default. aspx page i call

C#
lbluser.text="welcome" User.Identity.Name


and i also put loginstatus control and loginview to put admin link. i don't want to use thes two controls.
can anyone tell me the coding to do thes two functionalites in C#

C#
protected void btnLogin_Click(object sender, EventArgs e)
   {
       ecprops _user = new ecprops();
        dbcon dbo = new dbcon();
       _user = dbo.CheckUser(txtUserid.Text);
       if (_user != null)
       {
           if (_user.Password == txtPassword.Text)
           {
               FormsAuthenticationTicket Authticket = new FormsAuthenticationTicket(
                                                       1,
                                                       txtUserid.Text,
                                                       DateTime.Now,
                                                       DateTime.Now.AddMinutes(30),
                                                       chkRemeberMe.Checked,
                                                       _user.RoleName,
                                                       FormsAuthentication.FormsCookiePath);

               string hash = FormsAuthentication.Encrypt(Authticket);

               HttpCookie Authcookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);

               if (Authticket.IsPersistent) Authcookie.Expires = Authticket.Expiration;

               Response.Cookies.Add(Authcookie);

               string returnUrl = Request.QueryString["ReturnUrl"];
               if (returnUrl == null) returnUrl = "/";

               Response.Redirect(returnUrl);
           }
           else
           {
               lblMessage.Text = "Password does'nt match.";
           }
       }
       else
       {
           lblMessage.Text = "User not exists.";
       }
Posted
Updated 19-Sep-11 0:47am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900