我想出了一个对我们的部署 100% 有效的解决方案,所以我想我会分享它。
此解决方案将customErrors部分添加到web.config。这将捕获任何未处理的异常。它重定向到App_Offline.htm,它会刷新直到应用程序重新联机。所以用户得到了一个很好的加载器,当应用程序可用时它就会消失。
我希望这是有帮助的 :)
批处理文件
copy "C:\www\_App_Offline.htm" "C:\www\App_Offline.htm"
copy /y "C:\www\App_Offline.config" "C:\www\Web.config"
Rem do deploy/publish actions
Rem Note: Our publish replaces/restores the Web.config. You should do that here.
del "C:\www\App_Offline.htm"
App_Offline.config
<?xml version="1.0"?>
<configuration>
<system.web>
<httpRuntime waitChangeNotification="100" maxWaitChangeNotification="100"/>
<customErrors defaultRedirect="App_Offline.htm" mode="On">
</customErrors>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
_App_Offline.htm
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Application Offline</title>
<meta charset="UTF-8">
<style>
.facebook_blockG { background-color: none; border: 3px solid #D6D6D6; float: left; height: 40px; margin-left: 7px; width: 24px; opacity: 0; -moz-animation-name: bounceG; -moz-animation-duration: 1.3s; -moz-animation-iteration-count: infinite; -moz-animation-direction: linear; -moz-transform: scale(0.7); -webkit-animation-name: bounceG; -webkit-animation-duration: 1.3s; -webkit-animation-iteration-count: infinite; -webkit-animation-direction: linear; -webkit-transform: scale(0.7); -ms-animation-name: bounceG; -ms-animation-duration: 1.3s; -ms-animation-iteration-count: infinite; -ms-animation-direction: linear; -ms-transform: scale(0.7); -o-animation-name: bounceG; -o-animation-duration: 1.3s; -o-animation-iteration-count: infinite; -o-animation-direction: linear; -o-transform: scale(0.7); animation-name: bounceG; animation-duration: 1.3s; animation-iteration-count: infinite; animation-direction: linear; transform: scale(0.7); }
#blockG_1 { -moz-animation-delay: 0.39s; -webkit-animation-delay: 0.39s; -ms-animation-delay: 0.39s; -o-animation-delay: 0.39s; animation-delay: 0.39s; }
#blockG_2 { -moz-animation-delay: 0.52s; -webkit-animation-delay: 0.52s; -ms-animation-delay: 0.52s; -o-animation-delay: 0.52s; animation-delay: 0.52s; }
#blockG_3 { -moz-animation-delay: 0.65s; -webkit-animation-delay: 0.65s; -ms-animation-delay: 0.65s; -o-animation-delay: 0.65s; animation-delay: 0.65s; }
@-moz-keyframes bounceG {
0% { -moz-transform: scale(1.2); opacity: 0.6; }
100% { -moz-transform: scale(0.7); opacity: 0; }
}
@-webkit-keyframes bounceG {
0% { -webkit-transform: scale(1.2); opacity: 0.6; }
100% { -webkit-transform: scale(0.7); opacity: 0; }
}
@-ms-keyframes bounceG {
0% { -ms-transform: scale(1.2); opacity: 0.6; }
100% { -ms-transform: scale(0.7); opacity: 0; }
}
@-o-keyframes bounceG {
0% { -o-transform: scale(1.2); opacity: 0.6; }
100% { -o-transform: scale(0.7); opacity: 0; }
}
@keyframes bounceG {
0% { transform: scale(1.2); opacity: 0.6; }
100% { transform: scale(0.7); opacity: 0; }
}
</style>
</head>
<body>
<div id="overlay" class="trans">
<div id="overlay-inner" class="trans login">
<h1 style="line-height:1em; font-size:30pt">Application Offline</h1>
<h2 style="line-height:1em; width:70%; margin:auto">application is offline for maintenance</h2>
<div style="width: 128px; margin:40px auto">
<div id="blockG_1" class="facebook_blockG">
</div>
<div id="blockG_2" class="facebook_blockG">
</div>
<div id="blockG_3" class="facebook_blockG">
</div>
</div>
</div>
</div>
<script type="text/javascript">
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
setTimeout(function () {
var loc = getParameterByName('aspxerrorpath');
loc = (loc) ? window.location.protocol + '//' + window.location.host + loc : window.location.href;
window.location.assign(loc);
}, 1500);
</script>
</body>
</html>