Using HTTPS In ASP.NET Core 2.0

Problem

How to ensure the use of HTTPS in ASP.NET Core.

Solution

Create an empty project and update Startup to add services and middleware for MVC, including the filter for HTTPS,

You could setup a redirect from HTTP to HTTPS on the web-server (e.g. IIS) or use middleware in ASP.NET Core,

Note

For testing in IIS Express, you can enable SSL from project Properties > Debug tab by checking the Enable SSL flag.

Source Code

GitHub