web.config错误失败,响应模式=“文件".

编程入门 行业动态 更新时间:2024-10-23 05:40:24
本文介绍了web.config错误失败,响应模式=“文件".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

根据 Microsoft的文档,对于静态(即HTML)内容,则每个错误的web.config均应读取responseMode="File".

According to Microsoft's documentation, for static (i.e. HTML) content, web.config should read responseMode="File" for each error.

当前,我的web.config包括

Currently, my web.config includes

<httpErrors errorMode="Custom"> <!-- remove statusCodes --> <error statusCode="404" path="/error/404.html" responseMode="ExecuteURL" /> </httpErrors>

这将返回正确的自定义错误页面,但返回200 OK状态代码.

This returns the correct custom error page, but returns a 200 OK status code.

当我将"ExecuteURL"更改为"File"时,服务器确实返回404,但是未显示自定义错误页面.相反,我收到消息您要查找的资源已被删除,名称已更改或暂时不可用."

When I change "ExecuteURL" to "File", my server does return a 404, but the custom error page is not displayed. Instead, I get the message "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

web.config应该如何读取,返回静态文件以及404?

How is web.config supposed to read, to return a static file, but also a 404?

编辑:在得知该标记适用于IIS< = 6.0

removed <customErrors> questions after learning that that tag is for IIS <= 6.0

推荐答案

很长时间以来,我一直在思考完全相同的问题.现在我偶然发现问题出在斜线字符中.

I was figthing with exactly same problem pretty long time. Now I found out by accident that the problem is in the slash character.

这对我有用-没有开始斜杠,并使用\代替/

this is working for me - no beginning slash and use \ instead of /

<error statusCode="404" path="Static\WebServer\PageNotFound.htm" responseMode="File" />

更多推荐

web.config错误失败,响应模式=“文件".

本文发布于:2023-11-12 04:24:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580503.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   模式   文件   web   config

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!