What would be the best approach for this?
Posted
by chobo
on Stack Overflow
See other posts from Stack Overflow
or by chobo
Published on 2010-06-02T17:40:24Z
Indexed on
2010/06/02
17:44 UTC
Read the original article
Hit count: 174
asp.net-mvc
|asp.net-mvc-2
I have a site which has an area that requires authentication. Right now I use the roles attribute on all the controllers in that area, and I run a query to retrieve that users ID, and all their settings.
It seems like a code or design smell to me that I am retrieving the userid and settings each time a controller in that area loads up? I'm not sure if I should be using sessions, or if ASP.Net MVC 2.0 provides some unique way to handle this. Another concern is security.
Overall, I don't really know which way to turn. Design wise I would like the userId and settings retrieved only once when the user logs into the area. Right now I grab the userId each time a controller loads up, and then if required, I query the database for their settings each time as well.
© Stack Overflow or respective owner