ASP.NET MVC Session.IsNewSession issue with Google Chrome

前端 未结 2 2028
悲哀的现实
悲哀的现实 2021-01-02 13:32

I\'m currently working on a Session expired piece of logic for my ASP.NET 3.5 MVC 2 project to log out a user and redirect them to the AccountController LogOn action.

<
2条回答
  •  时光说笑
    2021-01-02 14:26

    We can add session_start method in Golbal.asax file in MVC appliaction.

      protected void Session_Start(object sender, EventArgs e)
          {                    
           HttpContext.Current.Session.Add("UserId" , null);
          }
    

    Then when application starting your session will be created. and then session will be not isNewSession 'True', otherwise it will be always 'True'

提交回复
热议问题