SessionID keeps changing in ASP.NET MVC why?

前端 未结 8 1527
傲寒
傲寒 2020-12-08 02:02

I am trying to keep track of something and using the SessionID as they key to that object

However the SessionID every 2-3 reqiests changes shouldn\'t it remain the s

8条回答
  •  失恋的感觉
    2020-12-08 02:40

    You should initialize the Session object within Global.asax.cs.

    void Session_Start(object sender, EventArgs e)
    {
        HttpContext.Current.Session.Add("__MyAppSession", string.Empty);
    }
    

    This way the session will not change unless your browser window is closed.

提交回复
热议问题