0

I've got an MVC 4 site where I'm using Forms Authentication. I'm setting a cookie when a user logs in. The majority of my site does NOT require a user to be logged in though.

What I'd like to do, whenever a user FIRST accesses my site, I'd like to update my "LastLogon" that I have stored in my database table to the corresponding value (if Request.IsAuthenticated). But I don't want it to fire on EVERY page that the user accesses.

So, where do I track when the user first accesses my site? Is that in the Global.asax? Is Application_Start method for all first requests to a site, or is that when the website first loads after an iisreset?

asked Aug 7, 2014 at 17:37

1 Answer 1

0

I realized/found yesterday that in the Global.asax that there's a method available called "Session_Start". I believe that will work perfectly.

I could also use the Application_Request method, but I don't want to hit my SQL Server that often.

(I'm also thinking of adding it to the "Session_End" method in case they are on the site for along time...

Here's a link to the Global.asax methods available:

http://sandblogaspnet.blogspot.com/2008/03/methods-in-globalasax.html

Edit/Update:

I just stumbled across this article on CodeProject that appears to be the time that the cookie is ready:

http://www.codeproject.com/Articles/288631/Secure-ASP-NET-MVC-applications

answered Aug 14, 2014 at 17:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.