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
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
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.