自定义错误未在 ASP.NET MVC 站点上转发

发布于 2024-08-11 13:56:58 字数 216 浏览 5 评论 0原文

在我的网站上,损坏的链接会引发默认的“页面未找到”错误。在 web.config 中,我打开了 CustomErrors 并将 404 错误转发到自定义消息。

在我的开发盒上它可以工作,但在主机上却不能。

有什么想法吗? ASP.NET MVC 1.0、SQL 2005、IIS 6 主机(是的,我希望它是 IIS7 - 但他们想要向我收取移动站点的费用)。

提前致谢!

On my site, a broken link throws the default, page not found error. In the web.config I have turned on CustomErrors and forward 404 errors to a custom message.

On my dev box it works, on the host it does not.

Any ideas? ASP.NET MVC 1.0, SQL 2005, IIS 6 host (ya, I wish it was IIS7 - but they want to charge me to move the site).

Thanks in advance!

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

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

发布评论

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

评论(2

小伙你站住 2024-08-18 13:56:58

CustomErrors 只会针对实际分配给 .NET 处理的文件触发。在本地 Visual Studio 上,这涵盖了所有内容,但在 IIS6 中,它仅涵盖实际上与 .NET 直接相关的文件(.aspx、.ashx、.asmx 等)。这意味着,如果您想要所有内容都使用它,则必须添加 ISAPI 过滤器来绑定要由 .NET 处理的所有文件,这会带来开销,并且如果您定义了任何全局处理程序或 HttpModule,则可能会导致一些意外行为。

此页面 将帮助您配置通配符绑定(如果这是您想要走的路)

您是否考虑过将其放入 IIS6 配置 而不是 .NET?这对您来说可能比尝试在 IIS6 中使用 .NET 中的 CustomErrors 更简单。

顺便说一句,IIS7 集成管道模式不存在这些问题,并且默认情况下所有文件均由 .NET 处理。

CustomErrors will only fire for files which .NET is actually assigned to handle. On your local Visual Studio this covers everything, but in IIS6 it only covers the files that are actually directly related to .NET (.aspx, .ashx, .asmx etc). This means that if you want it for everything you have to add an ISAPI filter to bind all files to be handled by .NET, which comes with overheads and can cause some unexpected behavior if you have any global handlers or HttpModules defined.

This page will help you with configuring a wildcard binding if that's the road you want to go down

Have you considered putting it in the IIS6 configuration instead of .NET? This may be simpler for you than trying to use the CustomErrors from .NET in IIS6.

As a sidenote IIS7 integrated pipeline mode does not have these issues and all files are handled by .NET by default.

动次打次papapa 2024-08-18 13:56:58

machine.conf 设置可能会覆盖您的 web.config 设置。
您是否联系过您的主机并询问他们是否覆盖了 CustomErrors 标记?

It is possible a machine.conf setting is overwriting your web.config setting.
Have you contacted your host and asked them if they overwrite the CustomErrors tag?

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