Solved

Role Varification in OnloggedIn event

Posted on 2006-11-21
3
583 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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