By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,544 Members | 2,065 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,544 IT Pros & Developers. It's quick & easy.

Wierd results with Roles.IsUserInRole

P: n/a
I am using the Login control with ASP.NET 2.0.

I want the redirect page to go to a page BASED on the role the user is in.
Here's my code:

Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Login1.LoggedIn
If Roles.IsUserInRole("SiteAdministrator") = True Then
Response.Redirect("AdminsOnly/AdminHome.aspx")
Else
Response.Redirect("MembersOnly/MemberHome.aspx")
End If
End Sub

When I debug it and print this with a result of "True":
? Roles.IsUserInRole("SiteAdministrator") = True

I've also tried this with a result of "True":
? Roles.IsUserInRole(Me.Login1.UserName.ToString , "SiteAdministrator")

But, it KEEPS skipping to the Else part. Any ideas why? Any suggestions?

Thanks.
Jan 15 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Joe
Dear VB Programmer,
It may be the roles using IsInRole to be available after postback

Hope can help you!
Regards,
Joe Tsui

"VB Programmer" wrote:
I am using the Login control with ASP.NET 2.0.

I want the redirect page to go to a page BASED on the role the user is in.
Here's my code:

Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Login1.LoggedIn
If Roles.IsUserInRole("SiteAdministrator") = True Then
Response.Redirect("AdminsOnly/AdminHome.aspx")
Else
Response.Redirect("MembersOnly/MemberHome.aspx")
End If
End Sub

When I debug it and print this with a result of "True":
? Roles.IsUserInRole("SiteAdministrator") = True

I've also tried this with a result of "True":
? Roles.IsUserInRole(Me.Login1.UserName.ToString , "SiteAdministrator")

But, it KEEPS skipping to the Else part. Any ideas why? Any suggestions?

Thanks.

Jan 15 '06 #2

P: n/a
Thanks, but I'm not too sure what you're saying. Can you rephrase?

"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Dear VB Programmer,
It may be the roles using IsInRole to be available after postback

Hope can help you!
Regards,
Joe Tsui

"VB Programmer" wrote:
I am using the Login control with ASP.NET 2.0.

I want the redirect page to go to a page BASED on the role the user is
in.
Here's my code:

Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Login1.LoggedIn
If Roles.IsUserInRole("SiteAdministrator") = True Then
Response.Redirect("AdminsOnly/AdminHome.aspx")
Else
Response.Redirect("MembersOnly/MemberHome.aspx")
End If
End Sub

When I debug it and print this with a result of "True":
? Roles.IsUserInRole("SiteAdministrator") = True

I've also tried this with a result of "True":
? Roles.IsUserInRole(Me.Login1.UserName.ToString ,
"SiteAdministrator")

But, it KEEPS skipping to the Else part. Any ideas why? Any
suggestions?

Thanks.

Jan 15 '06 #3

P: n/a
Joe
Dear VB Programmer,
It may be :
Before the page finishing "End Sub", the
Roles.IsUserInRole("SiteAdministrator")
is still false

After the page finishing "End Sub", and then postback,
Roles.IsUserInRole("SiteAdministrator") will change to true

So Roles.IsUserInRole will be false if the page does not postback to the
server
and always ELSE

Hope can help you!
Regards,
Joe Tsui
"VB Programmer" wrote:
Thanks, but I'm not too sure what you're saying. Can you rephrase?

"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Dear VB Programmer,
It may be the roles using IsInRole to be available after postback

Hope can help you!
Regards,
Joe Tsui

"VB Programmer" wrote:
I am using the Login control with ASP.NET 2.0.

I want the redirect page to go to a page BASED on the role the user is
in.
Here's my code:

Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Login1.LoggedIn
If Roles.IsUserInRole("SiteAdministrator") = True Then
Response.Redirect("AdminsOnly/AdminHome.aspx")
Else
Response.Redirect("MembersOnly/MemberHome.aspx")
End If
End Sub

When I debug it and print this with a result of "True":
? Roles.IsUserInRole("SiteAdministrator") = True

I've also tried this with a result of "True":
? Roles.IsUserInRole(Me.Login1.UserName.ToString ,
"SiteAdministrator")

But, it KEEPS skipping to the Else part. Any ideas why? Any
suggestions?

Thanks.


Jan 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.