默认或自定义错误页面? - WebConfig 自定义错误 defaultRedirect

Default or custom error page? - WebConfig custom error defaultRedirect

准备考试,如果不在 customError 中指定错误代码,会得到默认错误页面吗?

我想既然你设置了 defaultRedirect,所有的错误,不管它们是否被特别说明,都会被发送到 defaultRedirect 页面。然而,我看到的练习题却恰恰相反。我查看了 documentation,我只能看到它说如果自定义页面不存在它指的是默认值

<customErrors mode="On" defaultRedirect="Error.htm">
  <error statusCode="500" redirect="/CustomError.html"/>
</customErrors>

原题

发生 400 级错误时,显示 ASP.NET 默认错误页面。 [对/错]

我相信这是假的,答案是真的。

Do you get the default error page if you don't specify the error code inside customError?

是的。如果您没有在 customError 中指定错误代码,将使用默认错误页面。如果在 customError 中指定错误代码,将使用指定的页面。当然,customError 仅适用于 ASP.NET 处理的元素,因此您可以获得 IIS 错误页面而不是 web.config 文件中列出的任何内容。

根据您链接到的文档,

When you define a custom error, ASP.NET assigns to it the standard error normally issued by the underlying service, such as IIS. For instance, if you define a custom error for the status code 404, ASP.NET will issue it anytime you refer to a non-existing .aspx page. The custom errors are only issued for those elements handled by ASP.NET. For instance, if you refer to a non-existing .htm page, IIS issues the standard 404 error.

要回答您提供的具体问题,

When a 400-level error occurs, the ASP.NET default error page displays. [True / False]

这是 True,因为 web.config 中没有为 400 级错误指定的页面,因此使用默认错误页面。这假定错误发生在 ASP.NET 应用程序中。