Reputation: 67
I've been storing things like user role, name etc.. in a session to pass each page and I notice the project i'm updating has been doing this by fetching the values from a SQL Server database on every pageload.
My Question is, which one is better practice to do this? On Session it's a bit annoying because I have to do many null checks unless i create a class to act as the user container and fetching data from SQL server every pageload seems like a big load on performance. Should I just keep doing it the session way? Seems more simple and more practical.
EDIT.
There's also this called membership in ASP.NET to store user role and set it on web.config but I haven't digged into it much
Upvotes: 0
Views: 235
Reputation: 66649
On each page load, usually you need to get data from the database – I do not see why this is an issue on performance in general.
On an asp.net application, you may have many pools that runs it. This is mean that you have different application that each one can serve your user at any time.
Moreover, each of this application have different memory, different static data, and they are not communicate together.
The one way this different asp.net application to communicate is with the use of a file, like a database.
The other way is to use some common service that they reference – and there is a service for session.
Upvotes: 1