Convert Microsoft.AspNetCore.Http.HttpRequest to HttpRequestMessage

后端 未结 3 1981
余生分开走
余生分开走 2021-02-02 09:37

I need to convert Microsoft.AspNetCore.Http.HttpRequest from an AspNetCore context to an HttpRequestMessage to pass to an HttpClient. Is there

3条回答
  •  情书的邮戳
    2021-02-02 10:00

    Both IHttpRequestMessageFeature and Microsoft.AspNetCore.Proxy are discontinued. IHttpRequestMessageFeature has been removed since ASP.NET Core 3.0.

    Microsoft now has a new reverse proxy nuget package Microsoft.ReverseProxy based on ASP.NET Core infrastructure. As per their docs, IHttpProxy for direct proxying scenario can:

    serve as the core proxy adapter between incoming AspNetCore and outgoing System.Net.Http requests. It handles the mechanics of creating a HttpRequestMessage from a HttpContext, sending it, and relaying the response.

    Here is an example.

提交回复
热议问题