0
votes

I have an ASP.NET Core 3.1 website hosted on Azure. Works great loading via the "mysite".azurewebsites.net URL. Still, when I try to access via my custom domain, configured via the "Custom Domains" option in the Azure portal, the site then starts throwing 307 redirect errors, redirecting to itself (subdomain => subdomain) repeatedly until the page bombs.

All of the DNS settings are configured via Cloudflare.

For the subdomain, I have a CNAME record defined, where the "name" is just the subdomain, and the "content" value is the "mysite".azurewebsites.net.

I also have another subdomain configured the EXACT the same way, but it's running ASP.NET Core 1.0.

I read a little about ASP.NET Core 3.1 having HTTPS on by default, but all my sites are running HTTPS already.

If the site is getting called via the subdomain.mydomain.com, yet transmitting a 307, with the same URL, where am I going wrong?

website redirecting (ASP.NET Core 3.1): https://d3.wrestlestat.com

azurewebsites version (ASP.NET Core 3.1): https://d3wrestlestat.azurewebsites.net

the different subdomain that works (ASP.NET Core 1.0): https://d2.wrestlestat.com

EDIT: Ok, I've figured out why it's throwing the redirect/error, it's because of this in the Startup.cs:

app.UseHttpsRedirection();

But, don't I want that? Why would commenting that out make everything work ok? If you navigate to the d3.wrestlestat.com, everything works fine now. But, I WANT to enforce HTTPS, or is this redundant for some reason?

1

1 Answers

0
votes

Check that you have set the TLS/SSL Settings of your Appservice plan to Https only = On?

With this on the http call should not reach your code, your will therefore not trigger a http 307 temporary redirect.

There are ways to implement a permanent redirect in code.