Hi all this is my first question in here ...
i'm using asp.net authentication form ... and i need to handle a special case
in case the index.aspx page is opened with a URL which includes a certain querystring ,,, i automatically make that user loggedin but it never work for me
what i did is that ...
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string userID = Request.QueryString["username"];
if (!String.IsNullOrEmpty(userID))
{
Guid gd = new Guid(userID.Trim());
if (!(gd == null))
{
MembershipUser user = Membership.GetUser(gd);
if (Membership.ValidateUser(user.UserName, "123456"))
{
Login ctllogin = (Login)LoginView1.FindControl("Login1");
TextBox txtuser = (TextBox)ctllogin.FindControl("UserName");
TextBox txtpwd = (TextBox)ctllogin.FindControl("Password");
txtuser.Text = user.UserName;
txtpwd.Attributes.Add("Value", "123456");
Button btnLogin = (Button)ctllogin.FindControl("LoginButton");
btnLogin.Click += new System.EventHandler(LoginButton_Click);
LoginButton_Click(btnLogin, e);
}
}
}
}
}
then i forced the call of the Button Login click
protected void LoginButton_Click(object sender, EventArgs e)
{
string userID = Request.QueryString["username"];
if (!String.IsNullOrEmpty(userID))
{
Guid gd = new Guid(userID.Trim());
if (!(gd == null))
{
MembershipUser user = Membership.GetUser(gd);
if (Membership.ValidateUser(user.UserName, "123456"))
{
AuthenticateEventArgs eArg = new AuthenticateEventArgs();
Login_Authenticate(sender, eArg);
}
}
}
}
but even by forcing the button click it didnt fire the event logged_IN so i called the event
protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
{
string userID = Request.QueryString["username"];
if (!String.IsNullOrEmpty(userID))
{
Guid gd = new Guid(userID.Trim());
if (!(gd == null))
{
MembershipUser user = Membership.GetUser(gd);
if (Membership.ValidateUser(user.UserName, "123456"))
{
Login ctllogin = (Login)LoginView1.FindControl("Login1");
TextBox txtuser = (TextBox)ctllogin.FindControl("UserName");
TextBox txtpwd = (TextBox)ctllogin.FindControl("Password");
txtuser.Text = user.UserName;
txtpwd.Attributes.Add("Value", "123456");
e.Authenticated = true;
FormsAuthentication.RedirectFromLoginPage(txtuser.Text, false);
}
}
}
but even that didnt enable me to make that user's status to be logged_in what is missing in here ??
please help .. than on advanced
i'm using asp.net authentication form ... and i need to handle a special case
in case the index.aspx page is opened with a URL which includes a certain querystring ,,, i automatically make that user loggedin but it never work for me
what i did is that ...
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string userID = Request.QueryString["username"];
if (!String.IsNullOrEmpty(userID))
{
Guid gd = new Guid(userID.Trim());
if (!(gd == null))
{
MembershipUser user = Membership.GetUser(gd);
if (Membership.ValidateUser(user.UserName, "123456"))
{
Login ctllogin = (Login)LoginView1.FindControl("Login1");
TextBox txtuser = (TextBox)ctllogin.FindControl("UserName");
TextBox txtpwd = (TextBox)ctllogin.FindControl("Password");
txtuser.Text = user.UserName;
txtpwd.Attributes.Add("Value", "123456");
Button btnLogin = (Button)ctllogin.FindControl("LoginButton");
btnLogin.Click += new System.EventHandler(LoginButton_Click);
LoginButton_Click(btnLogin, e);
}
}
}
}
}
then i forced the call of the Button Login click
protected void LoginButton_Click(object sender, EventArgs e)
{
string userID = Request.QueryString["username"];
if (!String.IsNullOrEmpty(userID))
{
Guid gd = new Guid(userID.Trim());
if (!(gd == null))
{
MembershipUser user = Membership.GetUser(gd);
if (Membership.ValidateUser(user.UserName, "123456"))
{
AuthenticateEventArgs eArg = new AuthenticateEventArgs();
Login_Authenticate(sender, eArg);
}
}
}
}
but even by forcing the button click it didnt fire the event logged_IN so i called the event
protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
{
string userID = Request.QueryString["username"];
if (!String.IsNullOrEmpty(userID))
{
Guid gd = new Guid(userID.Trim());
if (!(gd == null))
{
MembershipUser user = Membership.GetUser(gd);
if (Membership.ValidateUser(user.UserName, "123456"))
{
Login ctllogin = (Login)LoginView1.FindControl("Login1");
TextBox txtuser = (TextBox)ctllogin.FindControl("UserName");
TextBox txtpwd = (TextBox)ctllogin.FindControl("Password");
txtuser.Text = user.UserName;
txtpwd.Attributes.Add("Value", "123456");
e.Authenticated = true;
FormsAuthentication.RedirectFromLoginPage(txtuser.Text, false);
}
}
}
but even that didnt enable me to make that user's status to be logged_in what is missing in here ??
please help .. than on advanced