我们如何以编程方式在Web.Config文件中的system.web部分中操作sessionstate值。 [英] How can we manipulate sessionstate value in system.web section in Web.Config file programmatically .
问题描述
我们如何以编程方式在Web.Config文件中的system.web部分中操作sessionstate值。
就像我们可以在下面写的web.Config文件中的ConnectionString一样。
var configuration = WebConfigurationManager.OpenWebConfiguration(& quot;〜& quot;);
var section =(ConnectionStringsSection)configuration.GetSection(& quot; connectionStrings& ; quot;);
section.ConnectionStrings [& quot; MyConnectionString& quot;]。ConnectionString =& quot; Data Source = ...& quot ;;
configuration.Save();
How can we manipulate sessionstate value in system.web section in Web.Config file programmatically .
Like we can do for ConnectionString in web.Config file written below.
var configuration = WebConfigurationManager.OpenWebConfiguration("~");
var section = (ConnectionStringsSection)configuration.GetSection("connectionStrings");
section.ConnectionStrings["MyConnectionString"].ConnectionString = "Data Source=...";
configuration.Save();
推荐答案
这里回答类似的问题如何使用c#编辑Web.config文件 [ ^ ]和一篇文章 here [ ^ ]
Similar question answered here How to edit the Web.config file using c#[^] and a article here[^]
在引用这些链接后,您将对会话有完整的了解。 />
SessionState元素[ msdn ] [ ^ ]
Session-State Modes [ ^ ]
在ASP.NET中探索会话 [ ^ ]
关于......:笑:
After refering these links,you will have complete idea regarding session.
SessionState Element [msdn][^]
Session-State Modes[^]
Exploring Session in ASP.NET[^]
Regarding.. :laugh:
这篇关于我们如何以编程方式在Web.Config文件中的system.web部分中操作sessionstate值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!