asp.net Login Form

Joined
Jan 21, 2009
Messages
1
Reaction score
0
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top