HttpRuntimeSection.EnableHeaderChecking 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示是否启用标头检查。
public:
property bool EnableHeaderChecking { bool get(); void set(bool value); };
[System.Configuration.ConfigurationProperty("enableHeaderChecking", DefaultValue=true)]
public bool EnableHeaderChecking { get; set; }
[<System.Configuration.ConfigurationProperty("enableHeaderChecking", DefaultValue=true)>]
member this.EnableHeaderChecking : bool with get, set
Public Property EnableHeaderChecking As Boolean
属性值
true 如果启用了标头检查,则为否则,为 false. 默认值为 true。
- 属性
示例
以下示例演示如何使用该 EnableHeaderChecking 属性。
// Get the EnableHeaderChecking property value.
Response.Write("EnableHeaderChecking: " +
configSection.EnableHeaderChecking + "<br>");
// Set the EnableHeaderChecking property value to true.
configSection.EnableHeaderChecking = true;
' Get the EnableHeaderChecking property value.
Response.Write("EnableHeaderChecking: " & _
configSection.EnableHeaderChecking & "<br>")
' Set the EnableHeaderChecking property value to true.
configSection.EnableHeaderChecking = True
注解
此属性的目的是启用回车符和换行符的编码, \r 并在 \n响应标头中找到。
在出站响应标头中,由代码0x1F及以下代码表示的字符进行编码,以及字符0x7F(删除字符)。 唯一的例外是字符0x09(制表符)未修改。
此编码有助于避免注入攻击,这些注入攻击会攻击对标头包含的不受信数据进行回显的应用程序。
注释
此属性不适用于状态行本身(状态代码和状态说明),但应用于其他标头。 尽管 <可以在任何级别设置 httpRuntime> ,但此属性仅适用于计算机和应用程序级别。
当此属性是 true默认值时,响应标头中找到的 \r 或 \n 字符将编码为 %0d 和 %0a。 这通过使同一标头行的注入材料部分失败了标头注入攻击。 这可能会中断响应,但不应针对客户端打开攻击途径。 不过,无论如何,回显不受信任的数据绝不是个好主意。
重要
HTTP 标头延续依赖于跨越多行的标头,并且在其中需要换行。 如果需要使用标头延续,则需要将 EnableHeaderChecking 属性设置为 false。 由于查看标头会对性能造成影响,因此,如果确实要进行正确的检查,请关闭此功能可以提高应用程序的性能。 在禁用此功能之前,请确保已在这一方面采用正确的预防措施。