国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

在asp.net 2.0中的web.config文件中調用外部文件

2019-11-18 17:15:59
字體:
來源:轉載
供稿:網友

在一個工作項目或者工作小組中,有可能經常要轉換工作的調試環境,比如開發環境,測試環境,部署環境,這樣有可能要對web.config文件進行修改或改動,比如要改數據庫的連接字符串,角色配置,安全配置環境等,一不小心,很容易會發生遺漏等錯誤.在asp.net 2.0的web.config文件中,新加入了可以引入外部文件的新特性,
使到我們可以先預先搞好幾個文件,比如將經常要改動的部分,如數據庫連接串部分等,按不同的開發環境,分別寫成若干個xml文件,然后在web.config中把它們按需要調入進來.比如

我們先建立兩個目錄,一個叫test,一個叫developer,分別存放測試和開發時,用到的不同環境,比如
在devloper文件中建立一個developerconnectionstring.xml,內容如下

<connectionStrings>
<add name="connstr" connectionString=
"data source=./sqlexPRess;initial catalog=
northwind;integrated security=true"
providerName="System.Data.SqlClient"/>
</connectionStrings>
再建立一個develOperappsetingstring.xml如下<appSettings>
<add key="autoemail" value="abc@abc.com /> </appSettings>

 

再建立一個developermembership.xml如下

<membership defaultProvider="Northwind">
<providers>
<add name="Northwind"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="connstr"/>
</providers>
</membership>
同樣道理,可以在test目錄下,也建立相關類似的xml文件,然后,在web.config中,可以這樣調用了
<?xml version="1.0"?>
<configuration>
<appSettings configSource="developer/developerappsetingstring.xml"/>
<connectionStrings
configSource="developer/developerconnectionstring.xml" />
<system.web>
<membership
configSource="developer/developermembership.xml"/>
<compilation debug="true"/>
<authentication mode="Forms"/>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</configuration>
 可以看到,在web.config中,可以通過configsource屬性來讀取外部文件

jackyrong BLOG


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 和田县| 集安市| 武功县| 南皮县| 济源市| 沈丘县| 旬阳县| 江都市| 灵宝市| 临漳县| 连山| 永济市| 大庆市| 望都县| 张北县| 阳西县| 桐乡市| 苏州市| 临邑县| 洛南县| 定远县| 甘泉县| 荥阳市| 通河县| 临湘市| 铁岭县| 长武县| 九江市| 依安县| 莒南县| 宝兴县| 麻阳| 商南县| 临潭县| 建宁县| 云梦县| 集贤县| 博客| 白玉县| 武安市| 永州市|