Solved

Role Varification in OnloggedIn event

Posted on 2006-11-21
3
580 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
Comment Utility
Roles.IsUserInRole will be false if the page does not postback to the server.

Cheers!!!
0
 

Author Comment

by:Scripter25
Comment Utility
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
Comment Utility
You can choose any option where the code will get executed as a result of postback.

Try debugging.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

6 Experts available now in Live!

Get 1:1 Help Now