Last post Jul 20, 2015 05:24 AM by Zhi Lv - MSFT
Jul 16, 2015 08:45 PM|pavanlalit|LINK
I have the following requirement and here are my implementation details for this.
Statement:- There is a request page (abc.aspx) where user enter info. I will set a lock flag in DB when user edit something on Page and reset/Unlock the flag when his session timesout or closes the browser.
since editing is much of client side, I am using a Jquery Ajax call to server method(Static) and using another static method to set the flag in DB.
If a user opens multiple tabs, its considered as same session and thus I am storing this list in Session variable in my Static method and when Session times out I can use this list and unlock the requests in DB.
I am setting like this in my abc.aspx
listOfLockedReq = HttpContext.Current.Session["CurrentLockedReqIds"] != null ? (List<int>)HttpContext.Current.Session["CurrentLockedReqIds"] : new List<int>();
I am trying to access this in Session_End of Global.asax but its returning null or a different Session ID. Here is my snippet in Session End method of Global.asax
List<int> ListoflockedreqPerUser = (List<int>)(Session["CurrentLockedReqIds"]);
if (ListoflockedreqPerUser != null && ListoflockedreqPerUser.Count > 0)
foreach (var req in ListoflockedreqPerUser)
For some reason, I couldn't access the requestIds set in the session variable, anyone know why? or what am I doing wrong?
or Is there a better way of doing this? pls comment.
Jul 20, 2015 05:24 AM|Zhi Lv - MSFT|LINK
According to your code and description, I create a sample using your code, it worked well on my side. I can get the session value in Session_End event. I suggest you check the
this article, I found that:
The Session_OnEnd event is supported only when the session state
Mode property is set to
InProc, which is the default. If the session state
SQLServer, then the Session_OnEnd event in the Global.asax file is ignored. If the session state
Mode is set to
Custom, then support for the Session_OnEnd event is determined by the custom session-state store provider.
So, you could try to use Inproc mode.