0

I am migrating the asp.net web application to asp.net core 6.0. For handling inbound proxies i have followed the following Microsoft link;

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-7.0

Is there any link or guideline for managing outbound proxy?

I have tried this so far but not sure if this is a right way of managing outbound proxy.

public void ConfigureServices(IServiceCollection services)
    {
        services.AddHttpClient("SampleClient", client =>
            {
                client.BaseAddress = new Uri("https://sample.client.url.com");
            })
        .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
        {
            Proxy = new WebProxy("https://sample.proxy.url.com")
        });
    }

1 Answer 1

0

For windows server, you could also use the environment variable to set the proxy.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\testapplication1.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess">
        <environmentVariables>
          <environmentVariable name="http_proxy" value="proxyip"/>
          <environmentVariable name="https_proxy" value="proxyip"/>
        </environmentVariables>
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.