Michael Sterling
asked on
How do I add querystring parameters and values in my Authenticate routine?
I'm using a login control in my ASP .NET 3.5 [C#] web application and i'm wanting to add some information to the url that it gets redirected to once the user authenticates. How do I do this? See the code snippet below...
//so once a user clicks the login button my
//"onauthenticate" routine looks like this:
protected void myLogin_Authenticate(object sender, AuthenticateEventArgs e)
{
if ( Membership.ValidateUser(myLogin.UserName, myLogin.Password))
{
//HERE IS WHERE I THINK I NEED TO ADD INFO
//TO MY URL STRING SO THE REDIRECTED URL
//WILL CONTAIN QUERY STRING PARAMETERS AND
//VALUES BUT HOW DO I DO IT?
e.Authenticate = true;
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I am not clear what you are trying, you have already authenticated user and you can put parameters in url which can be used on page.
ASKER
so what i'm trying to do, is, in the example above you state i can simply do this:
Respons.Redirect("www.yourdomain.com/page.aspx?info1=abc&info2=123")
the part of it that confuses me is this: www.yourdomain.com/page.aspx
in my code sample below, i keep getting redirected back to the login page with this:
http://localhost/Login.aspx?ReturnUrl=%2fAddEditStudent.aspx%3fAccessLevel%3dQUSuperMan&AccessLevel=QUSuperMan
in the url...
Respons.Redirect("www.yourdomain.com/page.aspx?info1=abc&info2=123")
the part of it that confuses me is this: www.yourdomain.com/page.aspx
in my code sample below, i keep getting redirected back to the login page with this:
http://localhost/Login.aspx?ReturnUrl=%2fAddEditStudent.aspx%3fAccessLevel%3dQUSuperMan&AccessLevel=QUSuperMan
in the url...
redir = Request.QueryString["ReturnUrl"];
string[] usersBelongingToRole = Roles.GetRolesForUser(myLogin.UserName);
foreach (String s in usersBelongingToRole)
{
roles = String.Format(roles.ToString() + "{0}", s);
}
if (roles.IndexOf("QUSuperMan") != -1)
{
if (String.Compare(redir, "/AddEditStudent.aspx") == 0)
Response.Redirect("/AddEditStudent.aspx?AccessLevel=QUSuperMan");
}
else if (roles.IndexOf("QUCoach") != -1)
{
if (String.Compare(redir, "/AddEditStudent.aspx") == 0)
Response.Redirect("/AddEditStudent.aspx?AccessLevel=QUCoach");
}
else
{
if (String.Compare(redir, "/AddEditStudent.aspx") == 0)
Response.Redirect("/AddEditStudent.aspx?AccessLevel=QUStudent");
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
still working on this...
ASKER
thank you for you help
ASKER