Groups > Asp .Net > ASP dotNET Security > Re: Question about storing information from user




Question about storing information from user

Question about storing information from user
Tue, 1 Apr 2008 05:28:12 +0000
The title is horrible, but I couldn't think of how to word my issue exactly.

 

Here is my scenario --

For each user I have a record in a "users" database -- one of the
fields in the database is the user "level" which is essentially an
indicator of their privileges on the site. I'm still learning and have been
working on multiple iterations of a project site while I go and in a previous
iteration I just had a query I ran in each of my Page_Load functions that would
query the database and get this information.  

 

I would prefer to do this just once -- 

1) When the user logs in to the site

2) When the user accesses the first page if they already have a cookie set to
bypass login

 

I want to access the data at this point and store it in the session state so I
can use it without requesting it at each page.

 

I guess my question is where can I put code to ensure it gets hit not only when
the user actually LOGS in to the site but also when a user who has the
"remember me" type toggle checked returns to a page without going
through the log in page.  Is there a method that can be overridden in
MembershipProvider that is accessed in either case?

 

Just wondering what direction to look.

 

Thanks all
Post Reply
Re: Question about storing information from user
Tue, 1 Apr 2008 06:18:56 +0000
I would recommend you take a look at adding an event handler in your global.asax
for the AquireRequestState event and placing your code in this event handler. 
In your global.asax add:protectedvoid Application_AcquireRequestState(object
sender, EventArgs e)

{

 //Your code here

}

This event will be raised after the membership provider is called, so try
setting a break point here and seeing if you get the behavior you are looking
for.  You may need to add an if statement to check if the user is authenticated
by checking the Principal's IsAuthenticated property.  Hope this helps.
Post Reply
about | contact