Skip to content

Who can help me? using YARP in an ApiController. Thanks Very much! #2322

Answered by Tratcher
AtlantisDe asked this question in General
Discussion options

You must be logged in to vote

Start with the examples here: https://microsoft.github.io/reverse-proxy/articles/direct-forwarding.html

While it shows code in Startup and Map, most of that can be moved to a controller as well. Just be careful about the lifetime of the httpClient, you don't want to create a new one per request. You can store it in a static field.

I need to handle custom request information, such as adding the request header parameter "Content-Type": "application/x-www-form-urlencoded".

Is this a GET or POST request? Does it already have a Content-Type? You wouldn't usually just add/change the Content-Type header, you'd have to replace the contents of the request body as well. See https://microsoft.gith…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by karelz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feedback This issue is general feedback and doesn't represent actionable work.
2 participants
Converted from issue

This discussion was converted from issue #2320 on November 13, 2023 17:06.