Solved

Role Varification in OnloggedIn event

Posted on 2006-11-21
3
581 Views
Last Modified: 2008-08-23
The below code is not working for me at all. it gets to the if statement and reads it as false for both of the if statements. although if I manually set it up to go to a specific page after login and on that page provide a list box that displays the roles that the current user is in it will show the correct roles. Is this an issue with just the way that the Onloggedin event works?


protected void OnLoggedin(object sender, EventArgs e)
{


if (Roles.IsUserInRole("registered"))
{

Response.Redirect(

"~/home.aspx");
}


if (Roles.IsUserInRole("employer"))
{

Response.Redirect(

"~/employers/myprofile.aspx");
}

Session.Add(

"UIDGuid", userId);
}
0
Comment
Question by:Scripter25
  • 2
3 Comments
 
LVL 12

Expert Comment

by:sandip132
ID: 17992565
Roles.IsUserInRole will be false if the page does not postback to the server.

Cheers!!!
0
 

Author Comment

by:Scripter25
ID: 17992685
So forgive me if I am missing something but what you are saying overall is I would have to technically either have the form post back to itself and do a

if(isPostback)

{

if(Roles.IsUserInRole(Login1.UserName,"employer"))
{

 

 Or place the code onto the page load of whatever page I want it to post to. possibly a simple page that just decides where to send the user from there?

0
 
LVL 12

Accepted Solution

by:
sandip132 earned 500 total points
ID: 17992763
You can choose any option where the code will get executed as a result of postback.

Try debugging.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
getting id from database 5 37
Problem to page 4 74
Different Delete Messages 7 37
How to get the web content with different encodings 2 28
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now