session variables lost for some reason

后端 未结 5 677
说谎
说谎 2021-02-06 17:51

I try to setup a E-shop. Next to every item I\'ve an asp:imagebutton when this imagebutton is clicked I\'m checking whehter the session varialbe session[\"bas

5条回答
  •  长发绾君心
    2021-02-06 18:16

    Sounds like your appdomain is being recycled. Is your web.config compilation element set in debug mode? In debug mode, ASP.NET resets the appdomain every 15 dynamic compilations. When that happens, if your sessions are stored in memory (InProc mode - the default), they'll be lost.

    FYI, a dynamic compilation will occur whenever a file change happens on your site, like you editing an ASPX file, or an image being generated, or a web.config change.

    So either put the site into Release mode (), or increase the numRecompilesBeforeAppRestart value from 15 in web.config, or use a non-volatile session storage mode - e.g. SQL Session State.

提交回复
热议问题