差分
ナビゲーションに移動
検索に移動
// using System.Web.Hosting; using System.Web.configが置いてあるディレクトリのパスを取得する。Configuration; var path = HostingEnvironmentusing System.ApplicationPhysicalPathConfiguration;
// Web.configを開く。 Configuration webConfig = WebConfigurationManager.OpenWebConfiguration(path); // sessionStateエレメントを抽出する。 var config return = (SessionStateSection) webConfig.GetSection("system.web/sessionState"); }
== Web.configから特定エレメントを抽出する ==
Web.configの各エレメントには「[[ConfigurationSection クラス (System.Configuration)]]」から派生したマッピングクラスが用意されている。
<source lang="csharp">
public SessionStateSection GetSessionStateSection() { // Web.configを開く。configが置いてあるディレクトリのパスを取得する。 Configuration webConfig var path = WebConfigurationManagerHostingEnvironment.OpenMachineConfiguration(path)ApplicationVirtualPath;
</source>
== 関連項目 ==
* [[ASP.NET MVC]]
== 参考文献 ==
<references/>
== 外部リンク ==
{{stub}}