I am pretty new in ASP.NET c#. But i am getting a good hold of it. There are all the time new things a new learner comes up with though and spends hours together finding out a solution.
Here is my issue.
I have a ASP.NET membership setup. I have a asp login system on the website. I have created 2 roles Administrator and Users.
I have 1 user in Administrator and 1 in Users currently for my testing purpose.
Now when the user logs in to the system i want to check there roles and if the role of teh logged in user is Administrator then send them to a specific folder called admin or else send them to the default.aspx in root directory.
How do we find the Role of logged in user and redirect accordingly.
Thanks for your reply.
I was wondering what event should this mentioned if condition be placed in.
Should it be Islogged event or OnAuthenticate ?
I believe OnAuthenticate event is triggered when the Login button is clicked not on logging in.
Can you be more specific on the solution.
sunnysasp
None
0 Points
11 Posts
How to find Roles of Logged in User and send to different pages
Dec 06, 2012 07:04 PM|LINK
Hi,
I am pretty new in ASP.NET c#. But i am getting a good hold of it. There are all the time new things a new learner comes up with though and spends hours together finding out a solution.
Here is my issue.
I have a ASP.NET membership setup. I have a asp login system on the website. I have created 2 roles Administrator and Users.
I have 1 user in Administrator and 1 in Users currently for my testing purpose.
Now when the user logs in to the system i want to check there roles and if the role of teh logged in user is Administrator then send them to a specific folder called admin or else send them to the default.aspx in root directory.
How do we find the Role of logged in user and redirect accordingly.
Thanks in advance.
Sunny
oned_gk
All-Star
35810 Points
7314 Posts
Re: How to find Roles of Logged in User and send to different pages
Dec 07, 2012 12:25 AM|LINK
IF (user.isinrole("Administrator")) { }Suwandi - Non Graduate Programmer
sunnysasp
None
0 Points
11 Posts
Re: How to find Roles of Logged in User and send to different pages
Dec 07, 2012 02:04 AM|LINK
Hi one_gk,
Thanks for your reply.
I was wondering what event should this mentioned if condition be placed in.
Should it be Islogged event or OnAuthenticate ?
I believe OnAuthenticate event is triggered when the Login button is clicked not on logging in.
Can you be more specific on the solution.
Thanks again.
Sunny
oned_gk
All-Star
35810 Points
7314 Posts
Re: How to find Roles of Logged in User and send to different pages
Dec 07, 2012 02:44 AM|LINK
can you place it in default.aspx page_load event to redirect to spesific page?
Suwandi - Non Graduate Programmer
sunnysasp
None
0 Points
11 Posts
Re: How to find Roles of Logged in User and send to different pages
Dec 07, 2012 03:28 AM|LINK
Hi,
Why would i place it in Default.aspx ?
Now if the Login control is in Login.aspx how would this work ?
Sunny
oned_gk
All-Star
35810 Points
7314 Posts
Re: How to find Roles of Logged in User and send to different pages
Dec 07, 2012 03:50 AM|LINK
Suwandi - Non Graduate Programmer
Ruchira
All-Star
44216 Points
7184 Posts
MVP
Re: How to find Roles of Logged in User and send to different pages
Dec 16, 2012 04:06 PM|LINK
Hello,
See here
http://weblogs.asp.net/anasghanem/archive/2008/04/12/redirecting-the-users-to-different-pages-based-on-there-roles.aspx
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.