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
備註
這個建構函式 (Constructor) 會初始化此物件,如下所示:
Method =
POST
.QueryString 設定為空字串。
SuppressEntityBody =
false
.