FORMS AUTHENTICATION AND AUTHORIZATION

Carl Pieterson

Total Post:14

Points:98
Posted by  Carl Pieterson
 2019  View(s)
Ratings:
Rate this:

How to use Forms Authentication and Authorization in ASP.NET?

  1. Chris Anderson

    Post:65

    Points:455
    Re: Forms Authentication and Authorization

    In order to acheive your result first you have to write the some code in web.config file:

    <system.web>
           <authentication mode="Forms">
              <forms loginUrl="login.aspx" defaultUrl="Employee.aspx" />
           </authentication>

           <authorization>
              <allow users="aaa"/>
              <allow users="bbb"/>
              <deny users="*"/>
            </authorization>
    </system.web>

    Then you have to authenticate and authorized the user based on the user available in authorization part:

    string strId = Login1.UserName;
    string strPass = Login1.Password;
    if (strId == "aaa" && strPass == "aaa")
         FormsAuthentication.RedirectFromLoginPage(strId, false);
    else
         Login1.FailureText = "Invalid ID or Password";

    Thanks.

      Modified On Sep-20-2011 01:35:31 AM
  1. Carl Pieterson

    Post:14

    Points:98
    Re: Forms Authentication and Authorization

    Thanks Rohit for answering me.

      Modified On Sep-20-2011 09:36:36 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!