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

3
  • what is the type of Login1.Password Commented Nov 26, 2013 at 6: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. Commented Nov 26, 2013 at 6:39
  • okk...then it must be passed as parameter in Authenticate method...check the Damith answer Commented Nov 26, 2013 at 6:42

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.