existingResponse="PassThrough" 是什么意思?在 IIS 中是什么意思? [英] What does existingResponse="PassThrough" mean in IIS?

查看:39
本文介绍了existingResponse="PassThrough" 是什么意思?在 IIS 中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文档说

existingResponse="PassThrough"

如果存在现有响应,则保持响应不变.http://www.iis.net/configreference/system.webserver/httperrors#005

Leaves the response untouched if an existing response exists. http://www.iis.net/configreference/system.webserver/httperrors#005

但是现有响应存在"是什么意思?

But what does that mean by "existing response exists"?

例如我希望我的 customErrors 处理程序抑制 ASP.NET 响应,以便 IIS 认为该响应不存在.我该怎么做?

E.g. I want my customErrors handler to suppress the ASP.NET response, so that IIS would think that response doesn't exist. How would I do that?

推荐答案

有三个可能的值,来自架构:

There are three possible values, from the schema:

<attribute name="existingResponse" type="enum" defaultValue="Auto">
  <enum name="Auto" value="0" />
  <enum name="Replace" value="1" />
  <enum name="PassThrough" value="2" />
</attribute>

粗略地说,这是我的理解:

Roughly, here is how I understand this:

PassThrough - 保留现有的响应,只要有一个.您的应用程序逻辑可能不返回任何内容.在这种情况下,将使用此处定义的错误页面.

PassThrough - leaves the existing response alone, as long as there is one. It is possible that your application logic doesn't return anything. In that case the error page defined here is used.

Auto - 使用此节点中定义的 IIS 错误页面,除非您在 asp.net 中设置:

Auto - uses the IIS error pages as defined in this node except when in asp.net you did set:

Response.TrySkipIisCustomErrors = true;

如果您这样做了,则使用来自您的代码的响应.

if you've done that, the response from your code is used.

替换 - 始终使用 IIS 错误页面,即使开发人员已设置 TrySkipIisCustomErrors.

Replace - always uses the IIS error pages, even if the developer has set TrySkipIisCustomErrors.

最后一个选项似乎是您想要的.

The last option seems to be the one you want.

考虑:

existingResponse="PassThrough"

现在尝试打开一个不存在的asp.net页面,你会看到:

now try to open a non-existing asp.net page, you'll see:

即使资源不存在,运行时也会提供响应,并将其传递给浏览器.

Even though the resource was not there, the runtime provided a response, it is passed through to the browser.

现在,尝试打开一个不存在的 html 页面.这次我们仍然得到 404 状态,但页面为空.

Now, try to open a non-existing html page. This time we still get a 404 status but an empty page.

更改为:

existingResponse="Auto"

丢失的asp.net页面仍然显示asp.net错误页面,但是对于丢失的html页面,我们现在得到了IIS:

the missing asp.net page still displays the asp.net error page, but for the missing html page we now get the IIS one:

所以,总结一下:当查看缺失的 html 和 aspx 页面时existingResponse 值,我们得到不同的错误页面:

So, summarizing: when looking at missing html and aspx pages with different existingResponse values, we get different error pages:

                .html-404   .aspx-404   .aspx-500
--------------------------------------------------
Auto             IIS         asp.net    asp.net
PassThrough      -           asp.net    asp.net
Replace          IIS         IIS        IIS

这篇关于existingResponse="PassThrough" 是什么意思?在 IIS 中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆