开发和生产在ASP.NET应用程序不同的配置文件 [英] Different configuration files for development and production in ASP.NET application

查看:124
本文介绍了开发和生产在ASP.NET应用程序不同的配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个项目,我的工作,我们有三个配置文件的Web应用程序;
Web.Config中
Web.Config.TestServer
Web.Config.LiveServer

On a project I'm working on we have a web application with three configuration files; Web.Config Web.Config.TestServer Web.Config.LiveServer

当我们发布到测试服务器,Web.Config中被重命名为Web.Config.Development和Web.Config.TestServer被重命名为Web.Config中,使得该配置活跃应用程序。

When we release to the test server, Web.Config is renamed to Web.Config.Development and Web.Config.TestServer is renamed to Web.Config, making that configuration active for the application.

有相当繁重保持三个非常相似的配置文件更新,并且这个系统跨越多个这是该项目的一部分的应用程序使用;不只是网站。

It is quite onerous keeping three very similar configuration files up to date, and this system is used across a number of applications which are part of this project; not just the website.

在结构的差异是最常见的本地目录或路径,网址,IP地址,端口号和电子邮件地址。

The differences in configuration are most commonly local directories or paths, URLs, IPs, port numbers, and email addresses.

我在寻找一种更好的方式。

I'm looking for a better way.

推荐答案

虽然你的做法似乎有些单调乏味,我觉得这是最好的办法。

While your approach seems tedious, I find it to be the best approach.

我以前把我所有的配置在一个单一的web.config文件,并且根本就生产一节注释掉。

I used to keep all of my configurations in a single web.config file, and simply had the "production" section commented out.

在这之后不久,我不得不做一个混合测试,让我查找数据从生产服务器即将到来,但新的数据插入到测试数据库。在这一点上,我不得不开始计件mealing什么配置块的部分注释/取消注释,并成为一场噩梦。

Shortly after this I had to do a "hybrid" test where my lookup data was coming from the production server, but the new data was being inserted into the test database. At that point I had to start piece-mealing what parts of the configuration block to comment/uncomment, and it became a nightmare.

同样,我们有我们的服务器管理员从测试到生产完成实际的迁移,其中大部分是在没有足够的.NET流利知道如何管理的web.config文件中。它是更容易为他们只是看到一个.TEST或.prod文件迁移正确的一个。

Similarly, we have our server administrators do the actual migration from test to production, and most of them aren't fluent enough in .NET to know how to manage the web.config files. It is far easier for them to simply see a .test or .prod file and migrate the proper one up.

您可以使用像一个数据库来存储所有的配置,但你正在运行到抽象的另一层,你有管理上的事情上面。

You could use something like a database to store all your configurations, but then you're running into another layer of abstraction and you have to manage that on top of things.

一旦你得到的诀窍,或你的两个(或三个)配置文件将如何设置的模板,它成为一个更容易管理他们,你可以有你的测试服务器的配置被修改了,没有什么麻烦一些独特的测试

Once you get the knack or the template of how your two (or three) configuration files will be setup, it becomes a lot easier to manage them and you can have your test server configuration get modified for some unique testing without much hassle.

这篇关于开发和生产在ASP.NET应用程序不同的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆