{"id":220,"date":"2020-09-26T11:42:13","date_gmt":"2020-09-26T11:42:13","guid":{"rendered":"http:\/\/tutorials.moedesign.de\/blog\/?p=220"},"modified":"2020-09-26T11:42:13","modified_gmt":"2020-09-26T11:42:13","slug":"using-refit-with-factory-and-proxy","status":"publish","type":"post","link":"http:\/\/tutorials.moedesign.de\/blog\/using-refit-with-factory-and-proxy\/","title":{"rendered":"Using Refit with Factory and Proxy"},"content":{"rendered":"<p>Sometimes a webhost wants you to use a proxy to communicate via http with an API for example. If you use Refit in C# with Factory implementation you can use the following code:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n\nservices.AddRefitClient()\n.ConfigureHttpClient(c =&gt; c.BaseAddress = new Uri(Configuration.GetValue(&quot;The name of the value in your appsettings.json&quot;)))\n.ConfigurePrimaryHttpMessageHandler(() =&gt; new HttpClientHandler()\n{\nUseProxy = true,\nProxy = new WebProxy(&quot;http:\/\/yourProxyUrl:yourProxyPort&quot;, false),\nPreAuthenticate = true,\nUseDefaultCredentials = false\n});\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes a webhost wants you to use a proxy to communicate via http with an API for example. If you use Refit in C# with Factory implementation you can use the following code: services.AddRefitClient() .ConfigureHttpClient(c =&gt; c.BaseAddress = new Uri(Configuration.GetValue(&quot;The name of the value in your appsettings.json&quot;))) .ConfigurePrimaryHttpMessageHandler(() =&gt; new HttpClientHandler() { UseProxy = true, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/tutorials.moedesign.de\/blog\/using-refit-with-factory-and-proxy\/\" class=\"more-link\"><span class=\"screen-reader-text\">\u201eUsing Refit with Factory and Proxy\u201c <\/span>weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3,4,6,17],"tags":[37,40,42],"class_list":["post-220","post","type-post","status-publish","format-standard","hentry","category-asp-net-core-mvc","category-aspnetcorewebapi","category-asp-net-mvc","category-csharp-2","category-webhosting","tag-factory","tag-proxy","tag-refit"],"_links":{"self":[{"href":"http:\/\/tutorials.moedesign.de\/blog\/wp-json\/wp\/v2\/posts\/220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/tutorials.moedesign.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/tutorials.moedesign.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/tutorials.moedesign.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/tutorials.moedesign.de\/blog\/wp-json\/wp\/v2\/comments?post=220"}],"version-history":[{"count":0,"href":"http:\/\/tutorials.moedesign.de\/blog\/wp-json\/wp\/v2\/posts\/220\/revisions"}],"wp:attachment":[{"href":"http:\/\/tutorials.moedesign.de\/blog\/wp-json\/wp\/v2\/media?parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/tutorials.moedesign.de\/blog\/wp-json\/wp\/v2\/categories?post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/tutorials.moedesign.de\/blog\/wp-json\/wp\/v2\/tags?post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}