app_offline.htm 这么用


    app_offline.htm 这个文件是当web站点在重新发布时.net 自动生成的。发布过程中所有对该站点的请求都会被重定向到此页面,所以经常看到:一个显示“This application is currently offline. To enable the application, remove the app_offline.htm file from the application root directory.” 的页面。
    某日秋高气爽,就写了一个app_offline.htm文件,主要实现:
    (a) 文字提示用户:服务器正在更新版本,请稍后...
    (b) 用一小段 javascript 实现了在客户端定时重新访问站点
    最后要求实施人员以后更新站点时,一定要先把这个文件拷贝到站点根目录下,然后就可以放肆的进行任何更新。更新完毕后,再将该文件移走(更该文件名也可行)。
    这样,当我们在更新WEB站点时,如果用户访问该站点,就会看到这个提示页面。并且这个页面在客户端自动的定时重新访问服务器,于是用户也不用手动去拼命刷新页面,或者重新访问正确的路径,只要等到服务器更新完毕,这个页面就会自动跳转到有效的站点页面。

☆ 关于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>
    
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
    
<title>提示页面</title>
    
<style type="text/css">
        body
{ font-size:12px; }
        div
{ text-align:center; padding-top:30px; padding-bottom:30px; height:150px; line-height:200%; }
    
</style>
    
<script type="text/javascript">
        
var loadObj = null;
        window.onload 
= function() {
            loadObj 
= document.getElementById("loading");
            
if(loadObj)
            {
                setInterval(
"window.location.reload()"10000);
                setInterval(
'loadObj.innerText = loadObj.innerText.length < 10 ? (loadObj.innerText + ">") : ""'800);
            }
        }
    
</script>
</head>
<body scroll="no">
<div style="text-align:center;">
    
<fieldset>
        
<legend><span style="color:Red">温馨提示</span></legend>
        
<div id="errorContainer" style="color:Blue">
        服务器正在更新
        
<br />
        请稍候
<br /><span id="loading" style="color:Black"></span>
        
</div>
    
</fieldset>
    
</div>
</body>
</html>
posted @ 2010-04-06 02:47  凌空止水  阅读(549)  评论(0编辑  收藏  举报