<div class="top-tips" style="background-color: #FFF8D9;border-bottom: 1px solid #FEBE8F;height: 28px;overflow: hidden;text-align: center;width: 100%;"><span class="tips-wrap" style="height: 100%;line-height: 28px; font-size:12px; font-weight:bold; color:#FF6600">尊敬的用户,系统将在2020年4月29日 18点 至 23点进行停机维护,届时将无法提供服务,敬请谅解!</span></div>
<div class="top-tips" style="background-color: #FFF8D9;border-bottom: 1px solid #FEBE8F;height: 28px;overflow: hidden;text-align: center;width: 100%;"><span class="tips-wrap" style="height: 100%;line-height: 28px; font-size:12px; font-weight:bold; color:#FF6600">尊敬的用户,系统将在2020年4月29日 18点 至 23点进行停机维护,届时将无法提供服务,敬请谅解!</span></div>
前段时间,系统升级,由于系统更新发布时间较长,所以必须停掉站点进行更新。导致很多用户都来反馈系统无法访问,还认为站点被黑掉了。
所以经过那件事我们也在思考,如何做到不停机,进行热部署。
单机环境下(双机或是分布式系统不用考虑这个问题),app_offline.htm是个不错的选择,
当asp.net看到应用程序中app_offline.htm文件时,它会关闭应用程序的app-domain,然后将请求发给app_offline的内容。
所以,在维护,升级的时候,就不必停止你的WEB应用程序,而是一个友好的方式提示给用户,本网站正在更新的提示,这样体验会更友好。
1. 创建一个app_offline.htm的HTM页面文件,
<html><head><meta http-equiv="Content-Type"content="text/html; charset=gb2312"><title>站点更新中</title></head><style>div {background-color:#ffffcc;padding-top:10px;padding-bottom:10px;padding-left:10px;padding-right:10px;border-style:solid;border-color:Black;border-width:1px;}</style><body><div><h1>站点更新中</h1><p>站点更新中,请稍后访问。</p></div></body></html>
2. 将app_offline.htm放在你的网站根目录下。这样,任何外部的请求的话,都会马上被转移到该页面了。
需要注意的是:
(1)app_offline.htm 不能小于 512 字节。
(2)IIS 站点和进程池不需要停止。
(3)只有对.aspx文件的请求才自动转到app_offline.htm文件;如果请求的是.htm, .asp等文件,则不会转到app_offline.htm
jQuery
//关闭所有jquery AJAX缓存 统一设置访问异常错误提示(function ($) { $.ajaxSetup({ cache: false, //关闭AJAX缓存 error(xhr, status, error) { //ShowMessage("error", "请求失败,请稍后再试!"); } });})(jQuery);
关闭所有jquery AJAX缓存 统一设置访问异常错误提示
//拓展$.postJSON方法,使用方式和$.getJSON类似,只不过方法改为POST(function ($) { if ($.postJSON) return; $.extend({ postJSON: function (url, param, callBack) { $.ajax({ type: "POST", url: url || "", data: param || {}, dataType: "json", success: callBack || function () { } }); } });})(jQuery);
拓展$.postJSON方法
//将数字转换成金额显示function toMoney(num) { if (num) { num = num.toFixed(2); num = parseFloat(num); num = num.toLocaleString(); return num;//返回的是字符串23,245.12保留2位小数 } else { return ‘‘; }}
将数字转换成金额显示
//jquery form序列化转换为json对象(function ($) { $.fn.serializeJson = function () { var serializeObj = {}; var array = this.serializeArray(); //var str = this.serialize(); $(array).each(function () { if (serializeObj[this.name]) { if ($.isArray(serializeObj[this.name])) { serializeObj[this.name].push(this.value); } else { serializeObj[this.name] = [serializeObj[this.name], this.value]; } } else { serializeObj[this.name] = this.value; } }); return serializeObj; };})(jQuery);
form序列化转换为json对象
//时间格式化function timeFormatter(value) { if (!value) { return ""; } if (value.indexOf("/Date") === -1) { return value; } var da = new Date(parseInt(value.replace("/Date(", "").replace(")/", "").split("+")[0])); return da.getFullYear() + "-" + (da.getMonth() + 1) + "-" + da.getDate() + " " + da.getHours() + ":" + da.getMinutes() + ":" + da.getSeconds();}//日期格式化function dateFormatter(value) { if (!value) { return ""; } if (value.indexOf("/Date") === -1) { return value.split(‘ ‘)[0]; } var da = new Date(parseInt(value.replace("/Date(", "").replace(")/", "").split("+")[0])); return da.getFullYear() + "-" + (da.getMonth() + 1) + "-" + da.getDate() + " ";}
时间格式化
//文件大小转换function bytesToSize(bytes) { if (!bytes) { return ‘‘; } if (bytes == 0) return ‘0 B‘; var k = 1024, sizes = [‘B‘, ‘KB‘, ‘MB‘, ‘GB‘, ‘TB‘, ‘PB‘, ‘EB‘, ‘ZB‘, ‘YB‘], i = Math.floor(Math.log(bytes) / Math.log(k)); return (bytes / Math.pow(k, i)).toPrecision(3) + ‘ ‘ + sizes[i];};
文件大小转换