Session_End does not fire?

前端 未结 5 1512
眼角桃花
眼角桃花 2020-12-03 10:28

I want to sign out a user when his session times out. So used following code in Global.asax:

protected void Session_End(object sender, EventArgs e)
{
    For         


        
5条回答
  •  伪装坚强ぢ
    2020-12-03 10:48

    Are you sure that it never fires ?

    As I understand it Session_End has nothing to do with the current request because ASP.NET session is terminated by the timeout AFTER the last request from the client has arrived. The call to FormsAuthenticaion.SignOut manipulates authentication cookies and therefore has no effect without any connectivity from the client (browser).

    Take a look at this question (which has an answer) - the problem is more or less similar to yours so you might find a right solution:

    Session_End in Global.asax.cs not firing using forms authentication

    Hope this helps.

提交回复
热议问题