I'm working with a ASP.NET WebForms application running on .NET Framework 4.7.2 which is sitting behind an Azure Application Gateway. The gateway performs SSL hand-off so is adding a X-Forwarded-Proto="https"
header.
I also have a .NET Core API in which I can configure
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseForwardedHeaders();
app.UseHsts();
app. //...
}
This is documented here, but is specific to .NET Core.
I've been unable to find an equivalent of UseForwardedHeaders
for .NET Framework - is there an equivalent?
Also, the WebForms application is running on OWIN, so I can do something like this, but I'm not sure how to complete it.
public void Configuration(IAppBuilder app)
{
app.Use(async (context, next) =>
{
var forwardedProto = context.Request.Headers["X-Forwarded-Proto"];
if (forwardedProto.ToLower() == "https")
{
// what now?
}
await next();
});
}
Is there an out-of-the-box solution for .NET Framework, or advice on how best to handle this?
Scheme
underRequest
so you can't modify that. Means that you can pretty much leave it as is or rewrite to somewhere else (e.gcontext.Items
) so that it's there if someone needs it down the pipeline. – Innominate