Response.TrySkipIisCustomErrors 不起作用 [英] Response.TrySkipIisCustomErrors not working
问题描述
我有一个页面,我希望该页面返回 404 响应但保留在该页面上.请不要问为什么 - 即使在我与他讨论之后,客户也想要那样.
I have a page where i want the page to return a 404 response but remain on that page. Please don't ask why - the client wants it that way even after i discussed it with him.
我有一个用 C# 编写的 .net 页面,在 iis 8 下运行,应用程序池配置为在 4.0 集成模式下运行
I've got a .net page written in C# running under iis 8 and the app pool is configured to run under 4.0 integrated mode
当我在页面中将状态码设置为 404 时,它会被发送到为此站点设置的自定义 404 错误页面.谷歌搜索后,我找到了另一篇关于 SO 提及使用 Response.TrySkipIisCustomErrors 的帖子.从我阅读的内容来看,这听起来正是我所需要的.我尝试将其设置为 true,但它对页面的行为没有影响 - 仍然会被发送到在 iis 中设置的客户 404 错误页面.
When i set the statuscode to 404 in the page, it gets sent to the custom 404 error page that's set up for this site. After googling i found another post on SO mention using Response.TrySkipIisCustomErrors. From what i read it sounds like it's exactly what i need. I tried setting it to true and it had no effect in the behavior of the page - still get sent to the customer 404 error page that's setup in iis.
有人知道为什么这不起作用吗?
Anyone have any ideas why this isn't working?
推荐答案
嗯 - 这是第一次.我第一次在点击提交按钮之前设法找到答案:)
Well - this is a first. First time I managed to find the answer before hitting the submit button :)
找到这篇 IIS.net 文章:http://www.iis.net/configreference/system.webserver/httperrors然后让我找到了这个:http://msdn.microsoft.com/en-us/library/ms690576(v=vs.90).aspx
Found this IIS.net article: http://www.iis.net/configreference/system.webserver/httperrors which then lead me to find this: http://msdn.microsoft.com/en-us/library/ms690576(v=vs.90).aspx
向下滚动到解释 existingResponse
选项的含义的部分.我将我的设置为 Replace
,这意味着它完全忽略了 TrySkipIisCustomErrors
.将其更改为 Auto
并且它正在工作.
Scroll down to the part that explains what the options for existingResponse
mean. I had mine set to Replace
which means it ignores TrySkipIisCustomErrors
completely. Changed it to Auto
and it's working.
这篇关于Response.TrySkipIisCustomErrors 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!