使用优雅的方式对运行网站进行修改和升级

在对运行的网站进行修改和升级时,会给正在访问网站的用户显示一些错误(如:HTTP 404 - 未找到文件等)。为了使用户更清楚网站状态,可以使用 app_offline.htm 文件来定义更优雅和明确的异常信息。

下面是一个 app_offline.htm 的例子
<!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>系统升级中。。。</title>
</head>
<body>
    
<table border="0" align="center" cellspacing="1" cellpadding="3" 
            style
="width: 530px; margin: 15px 0px 0px 15px"
        class
="table_k_bg">
        
<tr>
            
<td class="table_k_bg2 str" style="height: 24px; 
                vertical-align: bottom; text-align: center"
>
                操作提示!
            
</td>
        
</tr>
        
<tr>
            
<td class="table_k_bg1 blue" style="text-align: center; 
                height: 126px; line-height: 30px; vertical-align: top; 
                padding: 20px 5px 0px 20px"
>
                对不起,系统正在升级,请稍后再试。
            
</td>
        
</tr>
    
</table>
    
<!--        
    Adding additional 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).
    
-->
</body>
</html>

编写完 app_offline.htm 后,当要对网站进行维护和升级时,将 app_offline.htm 复制到网站的根目录。在完成网站的维护和升级工作后,将 app_offline.htm 从网站的根目录移除。

在网站的根目录加入 app_offline.htm 后会对网站产生如下影响:
        1、引起 ASP.NET 应用程序停止运行
        2、引起全部动态请求都返回 app_offline.htm 文件的内容
       
注意:必须确认 app_offline.htm 文件的大小大于 512bytes,这样才可以关闭 IE 本身的友好 HTTP 错误。

IIS 服务器支持此种维护和升级方式。

posted on 2006-08-24 14:59  Easy Company  阅读(240)  评论(1)    收藏  举报

导航