HttpRequestMessageProperty.Headers Property
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Gets the HTTP headers from the HTTP request.
Namespace: System.ServiceModel.Channels
Assembly: System.ServiceModel (in System.ServiceModel.dll)
Property Value
Type: System.Net.WebHeaderCollectionReturns a WebHeaderCollection that contains the HTTP headers in the HTTP request.
The following code shows how to use this property to add custom headers to a message.
static Message BuildMessage() { Message messageToSend = null; HttpRequestMessageProperty reqProps = new HttpRequestMessageProperty(); reqProps.SuppressEntityBody = false; reqProps.Headers.Add("CustomHeader", "Test Value"); reqProps.Headers.Add(HttpRequestHeader.UserAgent, "my user agent"); try { messageToSend = Message.CreateMessage(MessageVersion.Soap11, "http://tempuri.org/IUntypedService/ProcessMessage", "Hello WCF"); } catch (Exception e) { Console.WriteLine("got exception when sending message: " + e.ToString()); } messageToSend.Properties[HttpRequestMessageProperty.Name] = reqProps; return messageToSend; }
Windows 8 Release Preview, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 SP2, Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.