是否可以从ASP.NET 4.0的“服务器错误”页面中删除信息? [英] Is it possible to remove information from Server Error pages in ASP.NET 4.0?

查看:57
本文介绍了是否可以从ASP.NET 4.0的“服务器错误”页面中删除信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了更好地向用户隐藏信息,我试图从标准ASP.NET错误屏幕中删除版本信息部分。

In order to better hide information from users, I'm trying to remove the Version information section from the standard ASP.NET error screen.

自定义错误已启用,但是在某些情况下,如果您设法将错误排除在自己的控制范围之外(也许是服务器问题?),则可以继续进行操作。 YSOD。我尝试更改web.config使其包含httpruntime设置,在该设置中您可以将enableVersionHeader设置为false,但版本信息仍会通过。

Custom errors are on, but, under certain circumstances, if you manage to get an error outside of your control (server issues perhaps?) then you can get through to the YSOD. I've tried changing the web.config to include the httpruntime setting where you can set enableVersionHeader to false but the version information still comes through.

此外,在Application_PreSendRequestHeaders方法中,我尝试从响应标头中删除 X-AspNet-Version,但由于web.config设置,该标头不存在。

Also, in the Application_PreSendRequestHeaders method, I've tried to remove "X-AspNet-Version" from the response headers but that header doesn't exist due to the web.config setting.

是什么我希望在这种情况下甚至可能存在该信息吗?

Is what I want even possible within this context or will that information always exist?

推荐答案

要从.NET错误页面(不是403、404等通用IIS错误)隐藏.NET版本信息,请使用空元素 defaultRedirect属性:

To hide .NET version information from .NET error pages (not generic IIS errors like 403, 404 etc.), use empty element without defaultRedirect attribute:

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly"/>
    </system.web>
</configuration>

之前:

之后:

要删除X-AspNet-Version HTTP响应标头,请在 httpRuntime 上将 enableVersionHeader 设置为 False 。元素:

To remove X-AspNet-Version HTTP response header, set the enableVersionHeader to False on httpRuntime element:

<configuration>
    <system.web>
        <httpRuntime enableVersionHeader="False"/>
    </system.web>
</configuration>

这篇关于是否可以从ASP.NET 4.0的“服务器错误”页面中删除信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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