在一个工作项目或者工作小组中,有可能经常要转换工作的调试环境,比如开发环境,测试环境,部署环境,这样有可能要对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"/><connectionStringsconfigSource="developer\developerconnectionstring.xml" /><system.web><membershipconfigSource="developer\developermembership.xml"/><compilation debug="true"/><authentication mode="Forms"/><authorization><deny users="?"/></authorization></system.web></configuration>
可以看到,在web.config中,可以通过configsource属性来读取外部文件
相关推荐
asp.net2.0的web.config的配置教学,全部是自己一个人作品的做的,绝对不是拿人家的上传的
ASP.NET2.0配置文件Web.config 详细解释.rar
ASP.NET 2.0开发指南.iso 包含《ASP.NET 2.0开发指南》随书光盘.msi
[新闻文章]iwms v5.0.1010 正式版 .Net2.0_iwms.zip源码ASP.NET网站源码打包下载[新闻文章]iwms v5.0.1010 正式版 .Net2.0_iwms.zip源码ASP.NET网站源码打包下载[新闻文章]iwms v5.0.1010 正式版 .Net2.0_iwms.zip...
[整站程序]游戏网站智能管理系统.net2.0_webgame.zip源码ASP.NET网站源码打包下载[整站程序]游戏网站智能管理系统.net2.0_webgame.zip源码ASP.NET网站源码打包下载[整站程序]游戏网站智能管理系统.net2.0_webgame....
在.net编程中,我们经常用到config文件来保存一些常用的应用程序配置信息,在WinForm中这个文件名字是app.config,在asp.net中叫web.config。这个.config文件其实就是一个xml文件,对它的读操作微软已经提供了一个类...
Professional ASP.NET 2.0 Special Edition.part3Professional ASP.NET 2.0 Special Edition.part3
Professional ASP.NET 2.0 Special Edition.part2Professional ASP.NET 2.0 Special Edition.part2
Professional ASP.NET 2.0 Special Edition.part1Professional ASP.NET 2.0 Special Edition.part1
ASP.NET配置文件Web.config <br>
微软官方教程 ASP.NET.2.0技术内幕.pdf
[ASP.NET.2.0.揭秘].Sams.ASP.NET.2.0.Unleashed.Jun.2006.chm ASP.NET 2.0 Unleashed is a revision of the best-selling ASP.NET Unleashed, by Microsoft Software Legend Stephen Walther. It covers ...
ASP.NET 配置文件 Web.config详细解释 认识Web.config文件 web.config配置文件(默认的配置设置) 等等
《ASP.NET 2.0 入门经典》将逐步引导您使用 ASP.NET 2.0 创建动态的、数据驱动的、复杂的Web站点。在本章结束时,我们将解释一些基本的想法并介绍一个完整的示例站点。然后将学习怎样使用 Visual Web Developer ...
Asp.Net2.0读取-修改-新增(配置文件web.config)可以是 ***.config里面有3个文件操作类,System.config,使用文档
微软官方 ASP.NET 2.0快速入门(6):ASP.NET 2.0 成员管理.rar
build.your.own.asp.net.2.0.web.site.using.c.sharp.and.vbbuild.your.own.asp.net.2.0.web.site.using.c.sharp.and.vb
ASP.NET2.0揭秘随书源码
ComponentArt Web.UI 2008.2 for ASP.NET 2.0 (2008.2.1175.2) Source
"Beginning ASP.NET 2.0 in C# 2005: From Novice to Professional steers you through the maze of ASP.NET web programming concepts. You will learn language and theory simultaneously, mastering the core ...