Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is HttpRequestMessage.Properties?

What is the purpose of HttpRequestMessage.Properties?

I'm wondering if it provides something useful for my application.

like image 804
Drahcir Avatar asked Aug 02 '13 08:08

Drahcir


People also ask

What is the use of HttpRequestMessage?

The HttpRequestMessage class contains headers, the HTTP verb, and potentially data. This class is commonly used by developers who need additional control over HTTP requests. Common examples include the following: To examine the underlying SSL/TLS transport information.

What is HttpRequestMessage c#?

HttpRequestMessage(HttpMethod, String) Initializes a new instance of the HttpRequestMessage class with an HTTP method and a request Uri. HttpRequestMessage(HttpMethod, Uri) Initializes a new instance of the HttpRequestMessage class with an HTTP method and a request Uri.


2 Answers

In Web Api it contains some special flags: http://www.strathweb.com/2013/08/asp-net-web-api-2-and-httprequestcontext/

For example, IncludeErrorDetail, IsLocal, ClientCertificate are stored in the dictionary, but have properties for easy access.

like image 86
Der_Meister Avatar answered Oct 09 '22 11:10

Der_Meister


I found this statement from THOMAS LEVESQUE'S .NET BLOG which is how I was hoping to use it. MS or other places don't really describe it correctly... that we can use it however we want to carry per request information. In my case, store information about the destination so that I can validate the certificate per destination.

Let's see how we can associate a timeout value to a request. The HttpRequestMessage class has a Properties property, which is a dictionary in which we can put whatever we need. We're going to use this to store the timeout for a request, and to make things easier, we'll create extension methods to access the value in a strongly-typed fashion:

like image 26
T Brown Avatar answered Oct 09 '22 11:10

T Brown