HttpRequestMessageProperty.Headers Property
.NET Framework 4
Gets the HTTP headers from the HTTP request.
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 7, Windows Vista SP1 or later, Windows XP SP3, 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.
