473,498 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

When are User Roles Initialized?

I've set up ASP.NET membership.

I can get the role(s) of the current user by calling
Roles.GetRolesForUser().

It seems like it would be a good idea to store some role-specific
calculations in the Session object so that I don't need to re-perform these
calculations for each page.

Questions:

1. Does storing data calculated from the current user's role in the Session
object seem like a good approach so I don't need to perform these
calculations again for each page?

2. Where would I do initialize this data? I tried placing code in the
LoggedIn event of my Login control. The problem is that
Roles.GetRolesForUser() seems to return an empty list at this point. I guess
it hasn't been initialized when this event is called. So where else could I
get it?

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 8 '07 #1
2 1564
Jonathan,

1. Yes, it does seem like a good approach.

2. It is a registered problem. It was discussed here
http://groups.google.com/group/micro...546baadef642cf

Scott Guthrie explained the problem and offered a workaround:
The authentication principal won't get set until the next request to the
web-server. But you can use the "UserName" property on the Usercontrol
within the LoggedIn event to identify the user.

You can then use the Role APIs and pass the user name to retrieve their role
information.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:uN**************@TK2MSFTNGP02.phx.gbl...
I've set up ASP.NET membership.

I can get the role(s) of the current user by calling
Roles.GetRolesForUser().

It seems like it would be a good idea to store some role-specific
calculations in the Session object so that I don't need to re-perform
these calculations for each page.

Questions:

1. Does storing data calculated from the current user's role in the
Session object seem like a good approach so I don't need to perform these
calculations again for each page?

2. Where would I do initialize this data? I tried placing code in the
LoggedIn event of my Login control. The problem is that
Roles.GetRolesForUser() seems to return an empty list at this point. I
guess it hasn't been initialized when this event is called. So where else
could I get it?

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 8 '07 #2
Ah, appears to be just what I was looking for.

Many thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:uK**************@TK2MSFTNGP05.phx.gbl...
Jonathan,

1. Yes, it does seem like a good approach.

2. It is a registered problem. It was discussed here
http://groups.google.com/group/micro...546baadef642cf

Scott Guthrie explained the problem and offered a workaround:
The authentication principal won't get set until the next request to the
web-server. But you can use the "UserName" property on the Usercontrol
within the LoggedIn event to identify the user.

You can then use the Role APIs and pass the user name to retrieve their
role information.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:uN**************@TK2MSFTNGP02.phx.gbl...
>I've set up ASP.NET membership.

I can get the role(s) of the current user by calling
Roles.GetRolesForUser().

It seems like it would be a good idea to store some role-specific
calculations in the Session object so that I don't need to re-perform
these calculations for each page.

Questions:

1. Does storing data calculated from the current user's role in the
Session object seem like a good approach so I don't need to perform these
calculations again for each page?

2. Where would I do initialize this data? I tried placing code in the
LoggedIn event of my Login control. The problem is that
Roles.GetRolesForUser() seems to return an empty list at this point. I
guess it hasn't been initialized when this event is called. So where else
could I get it?

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2549
by: Piyush Gupta | last post by:
Hi All, I am using following code snippet to add another user in Users.xml: ------------------------------------------------------------------- DataSet dstUsers = new DataSet();...
3
2660
by: Catherine Jo Morgan | last post by:
I have TblRoles and TblRoleTypes. The main reason for RoleTypes is to make it easier to categorize roles for people and organizations. For example, RoleType entries include Client roles, Climb...
1
1181
by: Charles | last post by:
Hello, I tried posting this yesterday, and I have not seen it yet this morning. Thinking that something went wrong getting this question posted I am posting it again. Sorry if this does end up...
1
1330
by: WebMatrix | last post by:
Hello! I am working on a web application with Windows Authentication. In WindowsAuthentication_Authenticate event of Global.asax file a user is Authenticated and User/Roles Array is loaded into...
1
3615
by: ^MisterJingo^ | last post by:
Hi all, I've been searching the net for a way to programatically add a user to a role on successful registration. Not finding anything useful I decided to experiment and came up with the...
1
1658
by: Chicagoboy27 | last post by:
I have all the following site map ... <siteMapNode url="nothing.aspx" title="nothing" description="Home" roles=""> <siteMapNode url="default.asp" title="Home" description="Home" roles="" />...
0
10979
by: jeremy | last post by:
Had a tough time figuring this one out and couldn't find a good solution, so I thought I would post this and hopefully it will help someone out. When using DataBind to dynamically bind a list to...
3
8934
by: =?Utf-8?B?Q2hhcmxlc0E=?= | last post by:
hi folks, I've got XP pro service pack 2 VS 2005 TSE with ASP.net 2.0 and C# I'm doing an example from Stephen Walther's so far excellent book and he has a whole load of stuff to add the...
14
3244
by: chromis | last post by:
Hi, I've been trying to implement a more OOP oriented approach to dealing with user security on one of my websites, and I am trying to validate the user against an array of roles, however I am...
0
7124
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6998
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1416
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.