You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @DavidBrower, sorry for the delay: I fractured my clavicle, and was out for a bit.
You don't need to return a response: the proxy function does everything for you. Check out this sample.
[Route("api/google/{**rest}")]public Task ProxyCatchAll(stringrest){// If you don't need the query string, then you can remove this.varqueryString=this.Request.QueryString.Value;returnthis.HttpProxyAsync($"https://google.com/{rest}{queryString}");}
For swagger purposes, I wanted to maintain the content model in the endpoint definition. Therefore I could manage to forward the content with the following code:
var httpProxyOptions = HttpProxyOptionsBuilder.Instance
.WithBeforeSend((c, hrm) =>
{
hrm.Content = new StringContent(JsonConvert.SerializeObject(requestModel), Encoding.UTF8, "application/json");
return Task.CompletedTask;
})
.Build();
I've been puzzling how to use AspNetCore.Proxy to forward a Post request to a Web API Controller. Currently, the code looks like this:
How would I rewrite this to use AspNetCore.Proxy?
The text was updated successfully, but these errors were encountered: