差分

ナビゲーションに移動 検索に移動

Web.config

370 バイト追加, 2012年4月2日 (月) 03:03
== Web.configから特定エレメントを抽出する ==
Web.configの各エレメントには「[[ConfigurationSection クラス (System.Configuration)]]」から派生したマッピングクラスが用意されている。
<source lang="csharp">
// using System.Web.Hosting; using System.Web.configが置いてあるディレクトリのパスを取得する。Configuration; var path = HostingEnvironmentusing System.ApplicationPhysicalPathConfiguration;
public SessionStateSection GetSessionStateSection() { // Web.configを開く。configが置いてあるディレクトリのパスを取得する。 Configuration webConfig var path = WebConfigurationManagerHostingEnvironment.OpenMachineConfiguration(path)ApplicationVirtualPath;
// Web.configを開く。 Configuration webConfig = WebConfigurationManager.OpenWebConfiguration(path);  // sessionStateエレメントを抽出する。 var config return = (SessionStateSection) webConfig.GetSection("system.web/sessionState"); }
</source>
== 関連項目 ==
* [[ASP.NET MVC]]
== 参考文献 ==
<references/>
== 外部リンク ==
{{stub}}
匿名利用者

案内メニュー