本文介绍了IIS上同一网站的两个实例,具有不同的web.config(两个不同的数据库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现同一网站( www.example.com )的某种配置,因此在IIS上,我想拥有两个带有两个应用程序池的实例,因此一个实例位于:

I want to implement some kind of a configuration of the same website (www.example.com) so on IIS I want to have two instances with two application pools so one instance located at:

c:\ Site1

第二个位于

c:\ Site2

两个站点都是100%相等的,唯一不同的是数据库连接字符串,每个站点都指向不同的数据库服务器.

both sites are 100% equal with the only exception of the database connection string, each one is pointing to a different database server.

因此,在DNS中将指向 www.example.com ,在IIS上,每个实例都将指向 www.example.com .

So in the DNS will be pointing to www.example.com and on IIS each instance will point to www.example.com.

我这样做是因为我需要每天使用新信息还原数据库,因此在当前情况下,我必须停止应用程序,还原数据库,然后重新启动应用程序,以便每次执行此操作时网站都会脱机

I'm doing this way because I need to restore the database daily with new information so in my current scenario I have to stop the application, restore the database and then restart the application so the website goes offline every time I do this.

因此,我正在考虑以这种方式进行操作,以便我可以停止 Site1 ,然后还原数据库,然后重新启动站点,并对 Site2

So I was thinking to do something this way so I can stop Site1 then restore the database then restart the site and do the same for the Site2

推荐答案

您可以拥有两个数据库,而不是复制网站.DB1和DB2.

Rather than duplicate the websites, you can have two databases e.g. DB1 and DB2.

如果DB1是活动的(在web.config中配置),请还原到DB2.然后,更新web.config以指向DB2.当前活动的请求将使用旧配置(指向DB1)完成,但是所有新请求将使用新配置(指向DB2).

If DB1 is active (configured in web.config), restore to DB2. Then, update web.config to point to DB2. Currently active requests will complete using the old configuration (pointing to DB1), but all new requests will use the new configuration (pointing to DB2).

更新

根据沉重的启动成本,您可以将两个网站分别创建为www1.example.com和www2.example.com,然后将第三个网站设置为www.example.com,该网站可以直接重定向到www1或www2,具体取决于准备好了.您可以在IIS中配置重定向,而无需html或ASP.Net页面即可完成重定向.

Based on your heavy startup cost, you can instead create the two websites as www1.example.com and www2.example.com, and setup a third site as www.example.com that simply redirects to either www1 or www2 depending on which one is ready. You can configure the redirection within IIS, no need for an html or ASP.Net page to accomplish the redirect.

这篇关于IIS上同一网站的两个实例,具有不同的web.config(两个不同的数据库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 09:43