Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > asp.net Login Form

Reply
Thread Tools

asp.net Login Form

 
 
engtota engtota is offline
Junior Member
Join Date: Jan 2009
Posts: 1
 
      01-21-2009
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve form field value if form is EncType=multipart/form-dataForm? Li Zhang ASP .Net 4 02-27-2009 01:23 AM
form based login in jboss using login-config not working manu Java 1 07-20-2008 10:49 PM
Login using NT login details from web form problems DavidADEW ASP .Net 2 09-01-2006 03:10 PM
<form>...</form> - how to supress blank space after </form> in IE? rob c Javascript 4 12-30-2005 06:10 PM
Main form and login form in different folders using Forms Authen Bruce ASP .Net Security 5 04-11-2005 09:17 PM



Advertisments