Enforcing HTTPS in ASP.NET Core
HTTPS is enabled by default on ASP.NET Core. The main middleware related to the HTTPS protocol is the HttpsRedirection middleware class, which enforces redirection from HTTP to HTTPS. Therefore, it is possible to call the UseHttpsRedirection extension method in the Startup class in order to enable the middleware.
Let's see how to enable and force HTTPS in an ASP.NET Core application running in a docker container. The first step is to generate a self-signed certificate used by the ASP.NET Core application that runs in the container. .NET Core provides a global tool that creates a self-signed certificate on your local environment called dotnet-dev-certs. We can proceed by installing this tool on our local environment ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access