WebHeaderCollection.IsRestricted Method (String, Boolean)
Tests whether the specified HTTP header can be set for the request or the response.
Assembly: System (in System.dll)
Parameters
- headerName
- Type: System.String
The header to test.
- response
- Type: System.Boolean
Does the Framework test the response or the request?
| Exception | Condition |
|---|---|
| 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.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.