Why does ASP.NET Core redirection not work even if I call UseHttpsRedirection?

AzureDevelopment 1 Reputation point
2021-07-27T09:54:06.34+00:00

I have a web application which uses ASP.NET Core 3.1 on an Azure AppService, combined with Azure AD B2C authentication.
In my Startup.cs code, I call UseHttpsRedirection, but when I visit the site with an empty browser cache / or a new incognito session, using the HTTP protocol, I don't get redirected to HTTPS. Because of this, the B2C authentication doesn't work, so my app is not working.

What is strange though, once you visited the HTTPS site, and then the HTTP one, you will see the redirection is working.

What are getting served here are static HTML and JS files, served by the ASP.NET Core self-hosted server (running on a Linux AppService).

What do I miss here? Do I need to make an additional setting in Azure or in my code? Or do I need another record in the DNS?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
Microsoft Security | Microsoft Entra | Microsoft Entra External ID
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 22,721 Reputation points Moderator
    2021-08-04T07:35:48.333+00:00

    Apologize for late response! Its seems that issue resolved here,

    Thanks for sharing the solution which helped you.

    Adding here this will help other community members having similar issue.

    120446-snagdemo-3-microsoft-azure.png

    To elaborate on HTTPS only feature-

    HTTPS only: ON this means, by default, anyone can still access your app using HTTP and using this feature On you can redirect all HTTP requests to the HTTPS port.

    HTTPS only: OFF this means, by default, anyone can access your app using HTTP.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.