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.
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");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With