所以我从来没有找到解决这个问题的方法,但我确实找到了我试图实现的替代方案。
基本上,我想为每个应用程序显示一个特定的“离线”页面,该页面将在站点离线时显示。这是我所做的...
我在 IIS 中创建了一个名为“_offline”的网站。然后,我为 Port: 80 添加了一个通用的“catch all”绑定,并将主机名留空。在接受此绑定之前,您可能需要禁用当前的默认网站。
创建一个 index.html 页面并将您想要显示的任何内容放入其中并将其作为“_offline”的默认页面。我将在下面包含一些运行良好的脚本。
现在您可以通过关闭您的网站进行测试,您应该会看到新的索引页面。如果您无法关闭该网站,请在您的主机文件中添加一个绑定到“testdomain.com”之类的任何内容,并将其指向您的服务器。在浏览器中输入它应该会显示您的离线页面。
请记住,只要您的 IIS 无法在进入的地址找到活动网站,此页面就会显示。根据您的设置,这可能会或可能不会接受,在这种情况下您不应该使用此方法。
现在是我的索引页。我放了一些 javascript 来确定用户试图访问的站点,然后显示 html 的一部分。我还有一个倒计时,它会运行并尝试每 10 秒刷新一次页面。
无论如何,这不是理想的结果,但它确实有效。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width = device-width">
<title>Under Maintenance</title>
</head>
<style>
body{
color:#014795;
}
.container{
max-width:650px;
margin:auto;
font-size:18px;
font-family:Arial, Helvetica, sans-serif;
padding:20pt;
text-align:center
}
#logo img {
max-width:100%;
}
a {
color: inherit;
text-decoration: none;
}
a:hover {
color: inherit;
text-decoration: none;
}
</style>
<body>
<table class="container">
<tr>
<td>
<span id="logo"></span>
<p>This site is currently under maintenance and will be available shortly.</p>
<p>We apologize for any inconvenience caused.</p>
<table style="text-align:left;margin:auto;">
<tr><td>Telephone:</td><td><a href="tel:+27111111111">+27 11 11 1111</a></td></tr>
<tr><td>Fax:</td><td>+27 11 111 2222</td></tr>
<tr><td>Email:</td><td><a href="mailto:support@fubar.com">support@fubar.com</a></td></tr>
</table>
<p>We will automatically try to reconnect you in <span id="timeleft"></span> seconds</p>
</td>
</tr>
</table>
<script type="text/javascript">
var refreshEvery = 10;
var currentSec = 0;
var timer = setInterval(function() {
currentSec++;
if (currentSec >= refreshEvery) {
clearInterval(timer);
location.reload();
}
document.getElementById("timeleft").innerHTML = "" + (refreshEvery - currentSec);
}, 1000)
document.getElementById("timeleft").innerHTML = "" + (refreshEvery - currentSec);
// Use this site to create a base64 image http://www.base64-image.de/step-1.php
if (document.domain.indexOf("stacksnippets") >= 0) {
// Cusomise the site here, you can also show hide html content.
document.body.style.backgroundColor = "black";
document.body.style.color = "white";
} else {
// put default stuff here
}
</script>
</body>
</html>