Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable HTTPS redirection in Azure Website

I have a very simple website I'm using for testing purposes that I want to support HTTP. Presently all HTTP requests are being automatically redirected to HTTPS. Here are the steps to reproduce the app:

In Visual Studio 2019 create a new ASP.NET Core Web Application. Choose ASP.NET Core 3.1 and Empty for the project template. Disable "Configure for HTTPS". Right-click the new project and select "Publish...". Publish the app to a new App Service.

After publishing browse to the website. It will redirect you to HTTPS. Here's what I've already tried to remedy this.

In the Azure portal configure the newly created app service. Ensure App service authentication is off. In TLS/SSL settings set "HTTPS Only" to off.

In Program.cs add the UseUrls option.

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseUrls("http://localhost:8001");
            webBuilder.UseStartup<Startup>();
        });

In launchSettings.json ensure the application URL uses http.

None of the above solutions have worked for me.

like image 347
Brian Heilig Avatar asked Dec 23 '22 18:12

Brian Heilig


1 Answers

If you're getting a 307 redirect, make sure you aren't calling app.UseHttpsRedirection(); in Startup.cs (thanks https://stackoverflow.com/a/61818466/40783)

like image 152
Lee Richardson Avatar answered Jan 04 '23 16:01

Lee Richardson