Solved

Role Varification in OnloggedIn event

Posted on 2006-11-21
3
585 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

688 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