Session state outside of page

B

bryan

Hello,

I have a an asp.net application in c#. The code behind files call
helper methods in regular c# classes.

For example, on some pages I check if the current user has permission
to use certain buttons. To do this I call the
SecurityHelper.GetAllowedRoles(string username....)

If the user is allowed, I enable the buttons.

But each call to GetAllowedRoles(...) accesses the database. Instead, I
want to add the retrieved info to the session state. However, the
Session object does not seem to be available from the SecurityHelper
class.

What is a good solution to this?

Bryan
 
G

Guest

If you are looking to access session object from a non code behind cs file ,
use HttpContext

HttpContext _context = HttpContext.Current;
string _something = _context.Session["yourvariablename"].ToString();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top