Monday, January 30, 2012

Forms Authentication

In Web Config:       

<authentication mode="Forms">
            <forms loginUrl="~/Default.aspx">
                <credentials passwordFormat="Clear">
                    <user name="user" password="password"/>
                    <user name="user2" password="password2"/>
          <user name="karthi" password="karthi"/>
                </credentials>
            </forms>
        </authentication>


In aspx.cs :

string username = txt1.Text;
            string password = txt2.Text;

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

                        

            if (FormsAuthentication.Authenticate(username, password))
                FormsAuthentication.RedirectFromLoginPage(username,true );
                     

         div1.InnerHtml  = "<font size=5 color=red><i><b>Invalid user</b></i></font>";







No comments:

Post a Comment