文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>在asp.net 2.0中的web.config文件中调用外部文件

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

时间:2011-01-16  来源:scgw

  使到我们可以先预先搞好几个文件,比如将经常要改动的部分,如数据库连接串部分等,按不同的开发环境,分别写成若干个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="[email protected] /> </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="developerdeveloperappsetingstring.xml"/>
<connectionStrings
configSource="developerdeveloperconnectionstring.xml" />
<system.web>
<membership
configSource="developerdevelopermembership.xml"/>
<compilation debug="true"/>
<authentication mode="Forms"/>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</configuration>

  可以看到,在web.config中,可以通过configsource属性来读取外部文件

相关阅读 更多 +
排行榜 更多 +
涂色我贼强安卓版

涂色我贼强安卓版

休闲益智 下载
脑细胞太牛了手机版

脑细胞太牛了手机版

休闲益智 下载
球球的冒险旅途

球球的冒险旅途

休闲益智 下载