User769474054 posted
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.
Soln:-
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
BLRequest.UpdateRequestLockStatus(requestId, currentUser.UID);
listOfLockedReq = HttpContext.Current.Session["CurrentLockedReqIds"] != null ? (List<int>)HttpContext.Current.Session["CurrentLockedReqIds"] : new List<int>();
listOfLockedReq.Add(Convert.ToInt32(reqID));
HttpContext.Current.Session["CurrentLockedReqIds"]=listOfLockedReq;
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)
BLRequest.UpdateRequestLockStatus(req, 0);
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.