Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

WebHeaderCollection.IsRestricted Method (String, Boolean)

Tests whether the specified HTTP header can be set for the request or the response.

Namespace:  System.Net
Assembly:  System (in System.dll)

static member IsRestricted : 
        headerName:string * 
        response:bool -> bool

Parameters

headerName
Type: System.String

The header to test.

response
Type: System.Boolean

Does the Framework test the response or the request?

Return Value

Type: System.Boolean
true if the header is restricted; otherwise, false.

ExceptionCondition
ArgumentNullException

headerName is a null reference (Nothing in Visual Basic) or Empty.

ArgumentException

headerName contains invalid characters.

The IsRestricted method returns true to indicate that a request or response header is restricted and must be set using properties instead of directly or is set by the system. The restricted headers are:

  • Accept

  • Connection

  • Content-Length

  • Content-Type

  • Date

  • Expect

  • Host

  • If-Modified-Since

  • Range

  • Referer

  • Transfer-Encoding

  • User-Agent

  • Proxy-Connection

The following example checks the IsRestricted property to see if any request headers are prohibited from being set.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft