Skip to content

[ASP.NET] Ionos Windows Hosting Proxy for Auth0

Georg Höller
Georg Höller
1 min read
[ASP.NET] Ionos Windows Hosting Proxy for Auth0
Photo by Patrick Tomasso / Unsplash

Yesterday I had a hard time figuring out how to get my asp.net core backend working on ionos with auth0 support. Logically, auth0 has to connect to their services from the ionos server to work correctly. Ionos does not allow data from external sites - so you have to use their proxy for that: Ionos Docs

I wasn't able to get the web.config example working so I dig a little bit deeper and found the following solution. May it safes you some headache.

Create the proxy http handler.

var proxyHpttClientHandler = new HttpClientHandler
{
  Proxy = environment.IsProduction() 
    ? new WebProxy("http://winproxy.server.lan:3128") 
    : null
};

Programm.cs

Add the handler everywhere you go to an external ressource. For my auth0 backend this means the following:

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
    options.BackchannelHttpHandler = proxyHpttClientHandler;
    ...
});

...

builder.Services.AddAuth0AuthenticationClient(config =>
{
  ...
}).ConfigurePrimaryHttpMessageHandler(() => proxyHpttClientHandler);

...

builder.Services.AddAuth0ManagementClient()
    .AddManagementAccessToken()
    .ConfigurePrimaryHttpMessageHandler(() => proxyHpttClientHandler);

Programm.cs

If you have further questions about this topic or need help with a problem in general, please write a comment or simply contact me at yesreply@georghoeller.dev :)
C#

Comments


Related Posts

Members Public

[ASP.NET Core 6.0 | Angular] Hosting with Ionos

Update for my previous posts about hosting an angular frontend and ASP.NET Core 6 backend. Prerequirements: * active ionos windows hosting subscription * asp.net core 6 project * buildable angular project Ionos Setup Open up your favorite FTP client and connect it to your ionos webspace. Create two new folders -

[ASP.NET Core 6.0 | Angular] Hosting with Ionos