HttpRequestMessageProperty 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 HttpRequestMessageProperty 类的新实例。
public:
HttpRequestMessageProperty();
public HttpRequestMessageProperty ();
Public Sub New ()
示例
下面的代码演示如何不通过显式调用构造函数来从消息实例化此类。
public void ProcessMessage(Message input)
{
try
{
Console.WriteLine("ProcessMessage: Message received: " + input.GetBody<string>());
HttpRequestMessageProperty reqProp = (HttpRequestMessageProperty)input.Properties[HttpRequestMessageProperty.Name];
string customString = reqProp.Headers.Get("CustomHeader");
string userAgent = reqProp.Headers[HttpRequestHeader.UserAgent];
Console.WriteLine();
Console.WriteLine("ProcessMessage: Got custom header: {0}, User-Agent: {1}", customString, userAgent);
}
catch (Exception e)
{
Console.WriteLine("ProcessMessage: got exception: " + e.ToString());
}
}
Public Sub ProcessMessage(ByVal input As Message) Implements IUntypedService.ProcessMessage
Try
Console.WriteLine("ProcessMessage: Message received: " & input.GetBody(Of String)())
Dim reqProp = CType(input.Properties(HttpRequestMessageProperty.Name), HttpRequestMessageProperty)
Dim customString = reqProp.Headers.Get("CustomHeader")
Dim userAgent = reqProp.Headers(HttpRequestHeader.UserAgent)
Console.WriteLine()
Console.WriteLine("ProcessMessage: Got custom header: {0}, User-Agent: {1}", customString, userAgent)
Catch e As Exception
Console.WriteLine("ProcessMessage: got exception: " & e.ToString())
End Try
End Sub
注解
此构造函数初始化对象的方式如下:
Method =
POST
.QueryString 设置为空字符串。
SuppressEntityBody =
false
.