forum

Home / DeveloperSection / Forums / Session variable value not always available in Global.asax Session_end

Session variable value not always available in Global.asax Session_end

Anonymous User312831-Aug-2014

When a user logs into the website, I am creating 5 session variables with some user related values (like userid,roleid etc..). Based on one of the values stored in a session variable, I have to update a record in the database. To do this I am writing the following code in the Session_End() event of Global.asax

if (Session["UserHistoryID"] != null)

        SessionUtility.UpdateDatabase(Convert.ToInt32(Session["UserHistoryID"]));

The problem here with this is when the Session times out and Session_End fires the Session variable Session["UserHistoryID"] is NULL some-time and the above condition fails and the record in the database is not updated. When this is tested in my local system it works fine but when I test this in production server some of the records are not getting updated

Some one please explain how the Session_End works exactly.



Updated on 01-Sep-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By