asp.net管理多个web.config文件 [英] asp.net managing multiple web.config files
问题描述
有人可以建议一种管理多个web.config文件的好方法吗?
Can anyone suggest a good way to manage multiple web.config files?
例如,我有一个开发web.config,我在本地计算机上使用了一个名为"localWeb.config"的程序,然后在生产环境中使用了一个名为"prodWeb.config"的程序.我保留了.config扩展名,因此没有人可以从Web服务器访问它们.
For example, I have a development web.config I use on my localmachine named "localWeb.config" and then one I use for production called "prodWeb.config". I keep the .config extensions so no one can access them from the web server.
例如,localWeb.config将具有与开发数据库的连接字符串,而prodWeb.config将具有与生产数据库的连接字符串.
localWeb.config will for example have a connection string to a development database while prodWeb.config has one to the production database.
当前,我正在使用一个postbuild事件,该事件会将localWeb.config或prodWeb.config的内容复制到web.config.效果很好,但我想知道是否有人知道更好的方法.
Currently, I am using a postbuild event that will copy the contents of localWeb.config or prodWeb.config to web.config. This works well but I was wondering if anyone knew of any better ways.
推荐答案
查看 Web部署工具:
以下只是其中一些任务 使用该工具即可完成:
Here are just a few of the tasks that be accomplished using the tool:
-
创建一个包含内容,配置和SQL的包 用于部署或共享的数据库 和其他人.
Create a package that contains content, configuration and SQL databases for deployment or sharing with others.
使用该软件包作为对应用程序进行版本控制或创建备份的方法.
Use the package as a way to version your application or create backups.
添加参数以替换连接字符串或其他值 软件包安装过程中的文件.
Add parameters to replace a connection string or other value in a file during install of a package.
使非管理员可以部署程序包并精细地控制其程序包 使用权.
Enable non-administrators to deploy packages and granularly control their access.
同步或迁移运行IIS 6.0和IIS的站点和服务器 7.0.
Synchronize or migrate both sites and servers running IIS 6.0 and IIS 7.0.
这篇关于asp.net管理多个web.config文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!