简体   繁体   中英

change session timeout in web.config programatically

I have a requirement where i have to change connection string and session time out programatically, both need to be written in web.config and saved on hard disk. I could change connection string as below but struggling to accomplish the same for session timeout, could that be done someways?

 var configuration = WebConfigurationManager.OpenWebConfiguration("~");
 var section = configuration.GetSection("connectionStrings");
 section.ConnectionStrings["MyConnectionString"].ConnectionString = "Data Source=...";
 configuration.Save();

This short question-answer string shows how to set the timeout programmatically . Like others have said, I'm not sure why you'd be required to do this but if you are, you are.

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