469,909 Members | 1,617 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

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 1451
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Piyush Gupta | last post: by
3 posts views Thread by Catherine Jo Morgan | last post: by
1 post views Thread by Charles | last post: by
1 post views Thread by WebMatrix | last post: by
1 post views Thread by ^MisterJingo^ | last post: by
1 post views Thread by Chicagoboy27 | last post: by
3 posts views Thread by =?Utf-8?B?Q2hhcmxlc0E=?= | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.