Redirect to absolute URL on timeout in ASP.NET Core 2.0 application

后端 未结 1 1939
-上瘾入骨i
-上瘾入骨i 2020-12-21 17:49

I\'m running an ASP.NET Core 2.0 application which utilises ASP.NET Identity hosted in Azure App Service behind an Application Gateway.

I\'ve set up a custom domain

相关标签:
1条回答
  • 2020-12-21 18:21

    Thank you Tratcher for your help on this.

    It seems the Azure Application Gateway does not add the X-Forwarded-Host header so adding the app.UseForwardedHeaders() middleware was futile. Instead, I've added a configuration value that holds the host of my current environment and overrides the 'Host' property of every request with the custom domain.

    app.Use((ctx, next) =>
    {
        ctx.Request.Host = new HostString(options.Value.CustomDomain);
        return next();
    });
    

    The ASP.NET Identity authentication middleware then uses this value to construct the redirect URL.

    I've also written Microsoft some feedback on this issue here, as I'm sure my use case cannot be uncommon.

    0 讨论(0)
提交回复
热议问题