问题
I have a web site where I use ASP.NET membership for managing user creation, login, role management. I use Visual Studio 2012. There are a lot of elements created by Visual Studio in web.config. One of the element related to session state is the following.
sessionState mode="InProc" customProvider="DefaultSessionProvider"
name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection"
In this link, it says that Custom provider is used when mode is set to Custom
. The first question is that if this is the case why Visual Studio generates the session state's mode attribute as InProc and at the same time sets a custom provider? The second issue is with the session state timeout. When I add a timeout value to session state, it doesn't timeout when the time is up.
sessionState mode="InProc" customProvider="DefaultSessionProvider" timeout="30"
Time out started working when I removed CustomProvider attribute. Does anybody have more inside to this situation?
回答1:
I realized that the issue about the time out has nothing to do with CustomProvider attribute. The problem was that forms time out and session state time out were set to different values. Once I set them to the same value, it started working.
But still the fact that Visual Studio creates sessionState element with mode = InProc and customProvider = DefaultSessionProvider is strange since Microsoft web site says that the only time customProvider is used is when mode is set to Custom.
来源:https://stackoverflow.com/questions/15704356/the-sessionstate-timeout-doesnt-work-with-the-defaultsessionprovider