WebHeaderCollection.IsRestricted Method (String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

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

static member IsRestricted : 
        headerName:string -> bool

Parameters

headerName
Type: System.String

The header to test.

Return Value

Type: System.Boolean

true if the header is restricted; otherwise false.

Exception Condition
ArgumentNullException

headerName is null or Empty.

ArgumentException

headerName contains invalid characters.

The IsRestricted method returns true to indicate that a 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 headers are prohibited from being set.

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

.NET Framework
Available since 1.1
Return to top
Show: