title: Need help in login authentication using asp.net
body: <p>Simple way i am able to authenticate login page. How can i do that authentication in 3 tier architecture? please somebody send me the code that what should be in DAL,BAL,and GUI layers? Here is my simple code:</p>
  
  <p>Web.config:</p>
  
  <pre><code>&lt;authentication mode="form"&gt;
      &lt;form loginurl="Login.aspx"&gt;
           &lt;credential password Format="clear"&gt;
            &lt;user name="abcd" password="1234"&gt;
          &lt;/credential&gt;
        &lt;/authentication&gt;
       &lt;/form&gt;
     &lt;authorization&gt;
       &lt;deny users="?"&gt;
     &lt;/authorization&gt;
  </code></pre>
  
  <p>login.aspx.cs:</p>
  
  <pre><code>   sqlconnection con=new sqlconnection("server=localhost;database=dbname;uid=;pwd=;Trusted_Connection=true");
  sqldataAdapter da=new sqldataAdapter("select * from Login where UserName='"+TextBox1.Text+"' and Password='"+TextBox2.Text+"'",con);
  Dataset ds=new Dataset();
  da.Fill(ds);
  
  if(ds.Tables[0].rows.Count&gt;0)
  {
     if(FormAuthentication.Authenticate("abcd","1234")
     {
          FormAuthentication.RedirectFromLoginPage(TextBox1.Text,false);
          Response.write("Logged in");
      }
      else
      {
          Response.write("Unautherised User");
      }
  
     Response.Redirect("welcome.aspx");
  }
  else
  {
    Response.write("Sorry Invalid UserName or Password");
  }
  </code></pre>