Authentication For Beginners

Labels:

Authentication is the process of obtaining identification credentials such as name and password from a user and validating those credentials against some authority. If the credentials are valid, the entity that submitted the credentials is considered an authenticated identity. Once an identity has been authenticated, the authorization process determines whether that identity has access to a given resource.

There are three types of Authentication :

  • Forms authentication
  • Passport authentication
  • Windows authentication

Namespace used for authentication System.Web.Security

Example web config syntax:

<authentication mode="Forms">

<forms name="DBACookie" loginUrl="Login.aspx" protection="All" timeout="90" path ="/">

<credentials passwordFormat="Clear">

<user name="test" password="test"></user>

<user name="test1" password="test2"></user>

</credentials>

</forms>

</authentication>

Code Behind

if (FormsAuthentication.Authenticate(txtUser.Text,txtPass.Text))

{

FormsAuthentication.RedirectFromLoginPage(txtUser.Text,false);

Response.Redirect("./Home.aspx");

}

0 comments:

Post a Comment