简体   繁体   中英

How to determine the session type in asp.net

I want to change the session storage mode from inproc to some other third party session provider in my application. I have downloaded the standard provider written for it. I am using this provider in project and provided the server details in web config the session is working as expected. Problem I am facing is that even if I change the server details to any random ip, session code is still working. I am not able to determine if the session mode is getting changed internally after seeing invalid ip or something else is happening. I want to check in code which sessionstate mode my Application is using. How can I do that?

Use the following:

System.Web.HttpContext.Current.Session.Mode

Which returns SessionStateMode enum value which is one of the following:

  • InProc mode, which stores session state in memory on the Web server. This is the default.

  • StateServer mode, which stores session state in a separate process called the ASP.NET state service. This ensures that session state is
    preserved if the Web application is restarted and also makes session
    state available to multiple Web servers in a Web farm.

  • SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is
    restarted and also makes session state available to multiple Web
    servers in a Web farm.

  • Custom mode, which enables you to specify a custom storage provider.

  • Off mode, which disables session state.

Source: MSDN

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM