How to access the current HttpRequestMessage object globally?

It’s not impossible as I have just recently found out. It’s actually added into the Items property of the current HttpContext (if there is one) =[

HttpRequestMessage httpRequestMessage = HttpContext.Current.Items["MS_HttpRequestMessage"] as HttpRequestMessage

Edit:

This is as of WebAPI v2 .. I cannot be sure of previous versions.

Leave a Comment