Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could I read session state information in web.config

I configured session state in web.config.

<sessionState cookieless="AutoDetect" timeout="5" sqlConnectionString="....."/>

Now, I want to know timeout and sqlConnectionString from code-behind. Please, help me.

like image 998
zanhtet Avatar asked Jun 08 '11 04:06

zanhtet


1 Answers

You can use Session.Timeout to know timeout value.

However, better way is to use configuration API to read configuration. In this case, use code given below to get reference to session state configuration and then use properties such as SqlConnectionString and Timeout to find the necessary configured values.

using System.Web.Configuration;

...

var sessionSection = (SessionStateSection)WebConfigurationManager.GetSection("system.web/sessionState");
like image 55
VinayC Avatar answered Sep 23 '22 17:09

VinayC