I need to convert Microsoft.AspNetCore.Http.HttpRequest from an AspNetCore context to an HttpRequestMessage to pass to an HttpClient. Is there a simple way of achieve this? Or any hint to implement this would be very helpful.
Update I want to convert the request into a message but I want to change the target url, I want just to redirect the request into another server.
Try Web API Compatibility Shim
HttpRequestMessageFeature hreqmf = new HttpRequestMessageFeature(httpRequest.HttpContext); HttpRequestMessage httpRequestMessage = hreqmf.HttpRequestMessage;
Or you could get inspired by Microsoft.AspNetCore.Proxy
These extensions to httpContext may come in handy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With