In my next article
MVC Basic Site: Step 4 – jqGrid Integration in MVC 4.0 using AJAX, JSON, jQuery, LINQ, and Serialization[
^] I have provided an ASP.NET MVC application skeleton that manage the Visitors logs. Now only the user name,login date, the logout date and if was timeout or not are stored but could be extended to store as many info as you wanted.
1.First you have to extend the existing tables and at least the table
VisitorLogs
;
2. Then you should add your inspection code into the next method from
BaseController
class:
protected override void ExecuteCore()
. This method is executed in response to each user action request (from the web pages) just before the current action to be executed, so by using the next code:
System.Web.Routing.RouteValueDictionary routeValues = this.Url.RequestContext.Data.Value;
string controller = routeValues["controller"];
string action = routeValues["action"];
you will know the current controller and action that the user want to execute and you could stores this info into the
VisitorLogs
table.
3.To stores the info from the 2nd step your should extend the class
VisitorLog
with a new method similar with
OnUserLogin()
.