• atwiki
  • おのれ鍋奉行が!
  • web.configの設定記述を、外部ファイルに定義し、プログラム部分から取得する現在との差分

「web.configの設定記述を、外部ファイルに定義し、プログラム部分から取得する」の編集履歴(バックアップ)一覧はこちら

web.configの設定記述を、外部ファイルに定義し、プログラム部分から取得する - (2008/01/24 (木) 11:22:09) の最新版との変更点

追加された行は緑色になります。

削除された行は赤色になります。

*&this_page() **概要 1.web.configの設定記述を、外部ファイルに定義する。 2.プログラム部分から1を取得する。 **前提条件 -[[新しいwebサイトの作成]] **手順 custom.configというファイル名で以下を追加する。 #highlight(xml){{ <?xml version="1.0" encoding="UTF-8" ?> <appSettings> <add key="ConnectString" value="Provider=SQLOLEDB;Persist Security Info=True; Password=sa;User ID=sa;Initial Catalog=netinsider;Data Source=(local)" /> </appSettings> }} web.config中の「appSettings」に「file」を指定 #highlight(xml){{ <appSettings file="custom.config"/> }} default.aspx.vbで以下のように取得 #highlight(vb.net){{ Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Response.Write(System.Configuration.ConfigurationManager.AppSettings("ConnectString")) End Sub End Class }} 実行すると以下のような感じ。 #img(114.jpg)
*&this_page() **概要 1.web.configの設定記述を、外部ファイルに定義する。 2.プログラム部分から1を取得する。 元ネタ: -[[DOBON.NET / 「アプリケーション構成ファイル」を使用して設定を読み込む>>http://dobon.net/vb/dotnet/programing/appconfigfile.html]] **前提条件 -[[新しいwebサイトの作成]] **手順 custom.configというファイル名で以下を追加する。 #highlight(xml){{ <?xml version="1.0" encoding="UTF-8" ?> <appSettings> <add key="ConnectString" value="Provider=SQLOLEDB;Persist Security Info=True; Password=sa;User ID=sa;Initial Catalog=netinsider;Data Source=(local)" /> </appSettings> }} web.config中の「appSettings」に「file」を指定 #highlight(xml){{ <appSettings file="custom.config"/> }} default.aspx.vbで以下のように取得 #highlight(vb.net){{ Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Response.Write(System.Configuration.ConfigurationManager.AppSettings("ConnectString")) End Sub End Class }} 実行すると以下のような感じ。 ※ここでは外部ファイルから取得しているが、web.config内の記述も取得できる。 #img(114.jpg)

表示オプション

横に並べて表示:
変化行の前後のみ表示:
記事メニュー
目安箱バナー