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.
8,500 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
3,090 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 22,346 Reputation points
    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 Answers by the question author, which helps users to know the answer solved the author's problem.