From the course: Advanced Web APIs with ASP.NET Core in .NET 6

Unlock the full course today

Join today to access over 24,600 courses taught by industry experts.

Enforcing HTTPS

Enforcing HTTPS

- [Instructor] When we set up our API, there has been this checkbox Configure for HTTPS, and that was activated by default. When using the .NET CLI, the behavior that comes with Configure for HTTPS is on by default as well. But what exactly does that mean? Let's look at the project in the properties/launchsettings.json file, we see that there are two application URLs. One HTTPS URL, in my case it's using port 7233. And if you set up a new project you will, with very high probability, have different port. But there will also be an HTTP URL with another port that usually is just the HTTPS port -2000. And the same is the case here. So we have local host 5233 for HTTP and then we also have the HTTPS URL. In program CS what the checkbox actually does is the call to app.useHTTPSredirection() when the HDP URL. So technically when the web server receives a request on the HTTP port, then it redirects the same URL, but…

Contents