Hi, I am working in asp.net mvc4 web application here we have different modules. View, Controller, Service and Store.
View - cshtml page having normal html5 elementsand jquery functions
Controller - MVC Controller to access view and Service(here we done our business logic)
Service - Business Logic done here. we are using this service for reducing controller work load. Also we have interfaces, this classes are inherited from interfaces.
Store - Inherited from interface. Having logic to access database
In netshell, MVC -
M - (Interface, Service and Store)
V - Normal View
C - Normal Controller
based on this you can understand my project. Now i want to log user activities and store those in database. I have saved logs for User page navigation, login and Normal Logoff, But i am not able to save session_end time in database. My web.config code here
<sessionState mode="InProc" timeout="1"></sessionState> and my global.asax.cs page session end code here
public void Session_onEnd(object sender, EventArgs e)
{
var userLoggingActivityLog = new UserLoggingActivityLog
{
UserName = Session["username"].ToString(),
LogoffType = "Abnormal",
UserId = Convert.ToInt32(Session["userid"])
};
var userActivityLogService = DependencyResolver.Current.GetService<IUserActivityLogService>();
userActivityLogService.CreateUserLoggingActivity(userLoggingActivityLog, false);
Session.Clear();
Session.Abandon();
}
When sesseion_end method gets fire, In this particular line "var userActivityLogService = DependencyResolver.Current.GetService<IUserActivityLogService>();"null exception underhanded by user code error get produced. Can anyone help me how to solve this error and successfully call my interface to save session end time in database.