Home > Net >  ASP.Net Identity Login Redirect Enforce Protocol (Https) Part 2 (.Net 6 )
ASP.Net Identity Login Redirect Enforce Protocol (Https) Part 2 (.Net 6 )

Time:12-03

Prior reference (.Net Framework/ASP.Net MVC): enter image description here

  • the origin is https
  • the redirect uri sent to Google Auth is http - this will always fail

Can anyone point me to relevant docs/source on how to add/override options in .Net 6 and above? (similar to prior implementations in .Net Framework/MVC)?

CodePudding user response:

The answer is in the comment by @Tratcher:

Official Ref: Configure ASP.NET Core to work with proxy servers and load balancers

Essentially: ForwardedHeadersMiddleware

For my specific case:

In some cases, it might not be possible to add forwarded headers to the requests proxied to the app. If the proxy is enforcing that all public external requests are HTTPS, the scheme can be manually set before using any type of middleware:

...

app.Use((context, next) => {
context.Request.Scheme = "https";
return next(context); });

...

  • Related