bmanmike39
asked on
Page redirect baste on membership role. (asp.net 2.0 and c#)
I have 2 member ship roles in my site, directors and staff. After a user logs in, I would like to have a page load event, that would redirect the directors to a different start page. Can someone show me how i can do this with a simple if statement, in the page load event? Im working with ASP.Net 2.0 and C#.
Thanks for any help.
Thanks for any help.
ASKER
I understand the response redirect, I dont know how to write the code, for the user.name.identity. in other words,
If userneme = = directors
{
response.redirect(this url)
}
Something like the above.
If userneme = = directors
{
response.redirect(this url)
}
Something like the above.
Hi, do you mean how to check if the membership role equals certain value? It depends on what data type do you use to store the membership roles. Typically you would use integer, then the code would be like:
if (membershipRole == 0) // let's say director
Response.Redirect(... /* director page */);
otherwise, if it is a string:
if (membershipRole.Equals("Di rector"))
Response.Redirect(... /* director page */);
The value of membershipRole should be stored somewhere in database, eg:
user_id | login_name | password | membership_role
-------------------------- ---------- ---------- ---------- ----------
1 | abc | abc123 | 0
2 | def | def123 | 1
...
You need to use select query to get that based on the login name the user supplied
if (membershipRole == 0) // let's say director
Response.Redirect(... /* director page */);
otherwise, if it is a string:
if (membershipRole.Equals("Di
Response.Redirect(... /* director page */);
The value of membershipRole should be stored somewhere in database, eg:
user_id | login_name | password | membership_role
--------------------------
1 | abc | abc123 | 0
2 | def | def123 | 1
...
You need to use select query to get that based on the login name the user supplied
ASKER
Im using the Asp.net 2.0 membership provider, and i have the roles turned on. I need to get the role of the user from the provider. After the login page redirects to the start page.
I know how to get the users name for the provider, it User.Identity.Name but how do i get the users Role from the provider?
I know how to get the users name for the provider, it User.Identity.Name but how do i get the users Role from the provider?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Response.Redirect("http://your_url_here");