在维护期间用静态页面replace活动站点的最新方法?

好的伙计,

只是寻找他人在以下场景中使用的方法的一点洞察…

我有一个实时(.net 3.5)项目,从IIS7的默认文件夹(映射到已发布的wwwroot文件夹的“根目录”)运行。 当我们正在执行维护或升级(通过VS构build的Windows安装程序)时,我通常用静态页面replace应用程序来解释系统正在维护中。

我们将发布的网站移动到一个子目录(我们也认为它),删除旧版本,安装新版本,当我们感到高兴时,将其移回根目录(replace保留页面)。

必须有一个更简单,风险更低的方法来做到这一点。

其他人如何处理这种(或类似的)情况?

在IIS中,我使用了一个名为App_Offline的方法。 更多信息可以在Scott Gu的博客上find。

app_offline.htm的工作方式是将该文件放在应用程序的根目录下。 当ASP.NET看到它时,它将closures应用程序的应用程序域(而不是为请求重新启动它),而是返回app_offline.htm文件的内容以响应应用程序的所有新的dynamic请求。 当您完成网站更新时,只需删除该文件即可恢复在线状态。

我在讲话中指出的一件事是你想要关注的是IE6的一个名为“Show Friendly Http Errors”的特性。 这可以在IE中的工具 – > Internet选项 – >高级选项卡中进行configuration,默认情况下使用IE6。 当这个打开,并且一个服务器返回一个非HTTP-200的状态码,其内容less于512字节时,IE不会显示返回的HTML,而是replace自己的通用状态码消息(我个人认为这不是超级友善 )。

所以,如果你使用app_offline.htm特性,你应该确保你的内容至less有512字节的内容,以确保你的HTML(而不是IE的友好的状态信息)显示给你的用户。 如果你不想在页面上显示大量的文本,你可以使用的一个技巧就是添加一个HTML客户端评论和一些伪造的内容来推送它超过512字节。 例如:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Site Under Construction</title> </head> <body> <h1>Under Construction</h1> <h2>Gone to Florida for the sun...</h2> <!-- Adding additional hidden content so that IE Friendly Errors don't prevent this message from displaying (note: it will show a "friendly" 404 error if the content isn't of a certain size). <h2>Gone to Florida for the sun...</h2> <h2>Gone to Florida for the sun...</h2> <h2>Gone to Florida for the sun...</h2> <h2>Gone to Florida for the sun...</h2> <h2>Gone to Florida for the sun...</h2> <h2>Gone to Florida for the sun...</h2> <h2>Gone to Florida for the sun...</h2> <h2>Gone to Florida for the sun...</h2> <h2>Gone to Florida for the sun...</h2> <h2>Gone to Florida for the sun...</h2> <h2>Gone to Florida for the sun...</h2> <h2>Gone to Florida for the sun...</h2> <h2>Gone to Florida for the sun...</h2> --> </body> </html> 

在我们的姊妹网站StackOverflow上进行更多的讨论。