简体   繁体   English

为什么在某些情况下404页面不起作用? (IIS,经典ASP)

[英]Why does the 404 page not work in certain cases? (IIS, Classic ASP)

Explanation 说明

In production and locally, the 404 page for my site works fine for the most part. 在生产环境和本地环境中,我的网站的404页在大多数情况下都能正常运行。 A URL such as http://localhost:43424/gibberish_r3hjjnwef will return the well designed 404 HTML page that is in the website folder, and pointed to by IIS. 诸如http://localhost:43424/gibberish_r3hjjnwef类的URL将返回网站文件夹中并由IIS指向的精心设计的404 HTML页面。

However when I change the this URL to http://localhost:43424/gibberish_r3hjjnwef... it gives the following "hard" error, whilst still claiming to be a 404. 但是,当我将此URL更改为http://localhost:43424/gibberish_r3hjjnwef...时,出现以下“困难”错误,同时仍然声称自己是404。

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /gibberish_r3hjjnwef...

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2110.0

I'd rather it still gave the 404 HTML page. 我希望它仍然提供404 HTML页面。

I thought maybe it was an outright invalid URL, but both http://www.bbc.co.uk/news/fdisdhfdu and http://www.bbc.co.uk/news/fdisdhfdu... give the BBC's nice 404 page. 我以为这可能是一个完全无效的URL,但是http://www.bbc.co.uk/news/fdisdhfduhttp://www.bbc.co.uk/news/fdisdhfdu...都给BBC了好404页。

Question

Is there anything I can do to improve this? 有什么我可以做来改善的吗?

Relevant Information (happy to provide more if necessary) 相关信息(如有必要,乐意提供更多信息)

Microsoft .NET Framework Version: 4.0.30319 Microsoft .NET Framework版本:4.0.30319

ASP.NET Version: 4.7.2110.0 ASP.NET版本:4.7.2110.0

Language/Framework:C#/Classic .ASP 语言/框架:C#/经典.ASP

I'm not sure whether this is what you are referring to, but maybe try this out: 我不确定这是否是您所指的,但也许可以尝试一下:

Go to IIS Manager -> Site -> IIS Error pages. 转到IIS管理器->站点-> IIS错误页面。 On the right hand panel, there's a setting "Edit Feature Settings...". 在右侧面板上,有一个“编辑功能设置...”设置。

The options there mean: 那里的选项意味着:

  • Custom error pages: Use the 'IIS error pages' as fallback for all failed requests (eg your 404 page set up the list behind) 自定义错误页面:将“ IIS错误页面”用作所有失败请求的后备(例如,您的404页面设置了后面的列表)
  • Detailed error pages: In case of an Asp.Net error, shows the 'Asp.Net error page' ("Server Error in '/' Application." etc.) 详细的错误页面:如果出现Asp.Net错误,则显示“ Asp.Net错误页面”(“'/'应用程序中的服务器错误。”等)
  • Detailed errors for local requests etc.: Show the 'IIS error page' for remote requests, for local requests show the 'Asp.net error page' ("Server error in '/' etc.) 本地请求等的详细错误:对于远程请求,显示“ IIS错误页面”,对于本地请求,显示“ Asp.net错误页面”(“ //等服务器错误”)

This is in place to effectively hide the detailed Asp.net error page (with the stack trace etc.) from external callers as you may not want to give them the details of your application. 这样可以有效地向外部调用者隐藏详细的Asp.net错误页面(带有堆栈跟踪等),因为您可能不希望向他们提供应用程序的详细信息。 This is the default setting, where you should only see the 'Asp.net error page' when you call the invalid URL on 'localhost', but the 'IIS error page' (404) when you call the page from a different computer. 这是默认设置,当您在“ localhost”上调用无效的URL时,您应该只看到“ Asp.net错误页面”,而当从另一台计算机上调用该页面时,则仅会看到“ IIS错误页面”(404)。

So, what you may want to try is to select the "Custom error pages" option ('IIS error pages' for all failed requests). 因此,您可能想尝试的是选择“自定义错误页面”选项(所有失败请求的“ IIS错误页面”)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM