0
 if (Request.QueryString["Username"] != null)
    {
        Login1.UserName =Request.QueryString["Username"];
        Login1.Password = Request.QueryString["Password"];
     if (FormsAuthentication.Authenticate(Login1.UserName, Login1.Password))
        {
            FormsAuthentication.RedirectFromLoginPage(Login1.UserName, true);

        }

    }
     else{

        if (FormsAuthentication.Authenticate(Login1.UserName, Login1.Password))
        {
            FormsAuthentication.RedirectFromLoginPage(Login1.UserName, true);

        }
        }

How can i pass querystring password into Login1.Password.I am using FormsAuthentication methode for login.But Login1.Password doesnot accept value from querystring.Is Login1.Password give typeast error? Please help

Vishal Nagra
  • 59
  • 1
  • 6
  • what is the type of Login1.Password – A.T. Nov 26 '13 at 06:27
  • I also not know the type of Login1.But it give error Password.Property or indexer System.Web.UI.WebControls.Login.Password cannot assigned to its is read only. – Vishal Nagra Nov 26 '13 at 06:39
  • okk...then it must be passed as parameter in Authenticate method...check the Damith answer – A.T. Nov 26 '13 at 06:42

2 Answers2

1

You don't need Login control for Authenticate, give the user name and password as parameters

string username= Request.QueryString["Username"];
string password = Request.QueryString["Password"];

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

But sending Password as Query String is not recommended, You better read How to safely include password in query string

Community
  • 1
  • 1
Damith
  • 62,401
  • 13
  • 102
  • 153
1

You can directly pass query string parameters to Forms Authentication Authenticate function like following

if (Request.QueryString["Username"] != null && Request.QueryString["Password"] != null)
{

    if (FormsAuthentication.Authenticate(Request.QueryString["Username"].ToString(), Request.QueryString["Password"].ToString()))
    {
        // Authentication successful code

        FormsAuthentication.RedirectFromLoginPage(Request.QueryString["Username"].ToString(), true);
    }
    else
    {
        // Authentication unsuccessful code
    }
}
else
{
    // Parameter invalid or missing code
}