Force https with URL rewrite

For most sites, after installing a SSL certificate, https can be forced by adding a URL rewrite rule to the site's web.config file.  Though, please note it will not apply to all sites, for example it may not work for those using routing or it may conflict with any existing URL rewrite rules.  In the case of a CMS like WordPress or nopCommerce, it is often a setting within the CMS itself.  The URL rewrite rule also will not work for ASP.NET Core sites (see below).
URL rewrite rule to redirect all requests to https
<?xml version="1.0" encoding="UTF-8"?>
                <rule name="Redirect to https" stopProcessing="true">
                    <match url=".*" />
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
Rewrite in ASP.NET Core to redirect all requests to https
To use rewrite rules in an ASP.NET Core application, first download the Microsoft.AspNetCore.Rewrite library through NuGet.  In Visual Studio, Tools > NuGet Package Manager > Manage NuGet Packages for Solution... > Browse > in the Search field enter Microsoft.AspNetCore.Rewrite.  Highlight the package, click the checkbox next to your Project and Install.
Open the Startup.cs file and to the top of the file add:
using Microsoft.AspNetCore.Rewrite;
Then add the following to the Configure method:
app.UseRewriter(new RewriteOptions()