ASP.NET 2.0 - 如何使用 app_offline.htm

发布于 2024-07-29 00:49:24 字数 252 浏览 9 评论 0原文

我读过有关 app_offline.htm 文件,该文件可以放置在 .NET 2.0 应用程序的根目录中,该文件本质上会关闭该应用程序并禁止请求任何其他页面。

我已将该文件放置在根目录中,并且我的网站仍然可以加载。 我进入 IIS 中的默认文档并将其设置为 app_offline.htm 并且该网站仍然加载(但这可能是一个缓存问题)

无论如何,有人在使用这个时遇到问题吗? 难道我做错了什么?

I've read about the app_offline.htm file which can be placed within the root of a .NET 2.0 application which will in essence shut down the application and disable any other pages from being requested.

I've placed the file in the root, and my site still loads. I went into default documents in IIS and set it to app_offline.htm and the site still loads (this might have been a caching issue though)

Anyway, has anyone run into issues using this? Am I doing something wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

风月客 2024-08-05 00:49:24

我过去曾使用过非常方便的 app_offline.htm 技巧来关闭/更新网站,没有任何问题。

确保您确实将“app_offline.htm”文件放置在您在 IIS 中配置的网站的“根目录”中。

还要确保该文件的名称与应有的名称完全一致:app_offline.htm

除此之外,自处理该文件以来,您不需要对 IIS 进行任何其他更改(使用此文件)特定名称)由 ASP.NET 运行时而不是 IIS 本身处理(对于 IIS v6)。

但请注意,虽然将此文件放在站点的根目录中将强制应用程序“关闭”并显示“app_offline.htm”文件本身的内容,但任何现有请求都会仍然可以为他们提供真正的网站。 只有请求才会获取app_offline.htm内容。

如果您仍然遇到问题,请尝试以下链接以获取更多信息:

Scott Gu 的 App_Offline.htm

App_Offline.htm 和工作围绕“IE 友好错误”功能

app_offline.htm 会停止当前请求还是仅停止新请求?

I have used the extremely handy app_offline.htm trick to shut down/update sites in the past without any issues.

Be sure that you are actually placing the "app_offline.htm" file in the "root" of the website that you have configured within IIS.

Also ensure that the file is named exactly as it should be: app_offline.htm

Other than that, there should be no other changes to IIS that you should need to make since the processing of this file (with this specific name) is handled by the ASP.NET runtime rather than IIS itself (for IIS v6).

Be aware, however, that although placing this file in the root of your site will force the application to "shut down" and display the content of the "app_offline.htm" file itself, any existing requests will still get the real website served up to them. Only new requests will get the app_offline.htm content.

If you're still having issues, try the following links for further info:

Scott Gu's App_Offline.htm

App_Offline.htm and working around the "IE Friendly Errors" feature

Will app_offline.htm stop current requests or just new requests?

入怼 2024-08-05 00:49:24

确保您的 app_offline.htm 文件长度至少为 512 字节。 零字节的 app_offline.htm 将不起作用。

更新:较新版本的 ASP.NET/IIS 可能比我第一次写这篇文章时表现得更好。

更新 2: 如果您使用 ASP.NET MVC,请将以下内容添加到 web.config:

<?xml version="1.0"?>
<configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
    </system.webServer>
</configuration>

Make sure your app_offline.htm file is at least 512 bytes long. A zero-byte app_offline.htm will have no effect.

UPDATE: Newer versions of ASP.NET/IIS may behave better than when I first wrote this.

UPDATE 2: If you are using ASP.NET MVC, add the following to web.config:

<?xml version="1.0"?>
<configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
    </system.webServer>
</configuration>
滥情空心 2024-08-05 00:49:24

请注意,这在 IIS 6 和 7.x 以及 .NET 2、3 和 4.x 上的行为相同。

另请注意,当 app_offline.htm 存在时,IIS 将返回此 http 状态代码:

HTTP/1.1 503 Service Unavailable

这都是设计使然。 这允许您的负载平衡器(或其他)看到服务器已离线。

Note that this behaves the same on IIS 6 and 7.x, and .NET 2, 3, and 4.x.

Also note that when app_offline.htm is present, IIS will return this http status code:

HTTP/1.1 503 Service Unavailable

This is all by design. This allows your load balancer (or whatever) to see that the server is off line.

递刀给你 2024-08-05 00:49:24

可能的权限问题

我知道这篇文章相当老了,但我遇到了类似的问题,并且我的文件拼写正确。

我最初在另一个位置创建了 app_offline.htm 文件,然后将其移至应用程序的根目录。 由于我的设置,我遇到了权限问题。

该网站表现得好像它不存在一样。 在根目录中创建文件而不是移动它,解决了我的问题。 (或者您可以修复属性->安全中的权限)

希望它对某人有帮助。

Possible Permission Issue

I know this post is fairly old, but I ran into a similar issue and my file was spelled correctly.

I originally created the app_offline.htm file in another location and then moved it to the root of my application. Because of my setup I then had a permissions issue.

The website acted as if it was not there. Creating the file within the root directory instead of moving it, fixed my problem. (Or you could just fix the permission in properties->security)

Hope it helps someone.

绮烟 2024-08-05 00:49:24

确保 app_offline.htm 位于 IIS 中虚拟目录或网站的根目录中。

Make sure that app_offline.htm is in the root of the virtual directory or website in IIS.

伴梦长久 2024-08-05 00:49:24

确保文件扩展名在资源管理器中可见,并且文件名实际上是

app_offline.htm

而不是

app_offline.htm.htm

Make sure filename extensions are visible in explorer and filename is actually

app_offline.htm

not

app_offline.htm.htm

混浊又暗下来 2024-08-05 00:49:24

我遇到了一个与原来的问题非常相似的问题,我花了一些时间才解决。

以防万一其他人正在处理 MVC 应用程序并找到进入此线程的方式,请确保您有一个到定义的适当 .Net aspnet_isapi.dll 的通配符映射。 一旦我这样做,我的 app_offline.htm 就开始按预期运行。


IIS 6 配置步骤

在 IIS 应用程序属性上,选择虚拟目录选项卡。

在应用程序设置下,单击配置按钮。

在通配符应用程序映射下,单击插入按钮。

输入C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll,单击“确定”。

I ran into an issue very similar to the original question that took me a little while to resolve.

Just incase anyone else is working on an MVC application and finds their way into this thread, make sure that you have a wildcard mapping to the appropriate .Net aspnet_isapi.dll defined. As soon as I did this, my app_offline.htm started behaving as expected.


IIS 6 Configuration Steps

On IIS Application Properties, select virtual Directory tab.

Under Application Settings, click the Configuration button.

Under Wildcard application maps, click the Insert button.

Enter C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll, click OK.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文