Redirect HTTP to HTTPS in WEB.CONFIG compatible with IIS 8.5 (ASP.NET)
<p>Going bonkers here. I have a rule, to redirect ALL pages from <code>HTTP</code> to <code>HTTPS</code>, that worked just fine in <code>IIS8</code> but I get a <em>500 Internal Server Error in IIS 8.5.</em>  I figure there is some configuration I am missing, but at a loss after searching for hours and trying all kinds of different alterations of a rewrite rule in <code>system.WebServer</code> in the <code>web.config</code> file.
Here is the code (one of about 5 variations - none of which work)</p>

<pre><code>&lt;rewrite&gt;
  &lt;rules&gt;
    &lt;rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true"&gt;
        &lt;match url="(.*)" /&gt;
        &lt;conditions logicalGrouping="MatchAny"&gt;
          &lt;add input="{SERVER_PORT_SECURE}" pattern="^0$" /&gt;
        &lt;/conditions&gt;
        &lt;action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" /&gt;
    &lt;/rule&gt;
  &lt;/rules&gt;
&lt;/rewrite&gt;
</code></pre>

<p>Without simply writing this in the <code>MasterPage</code> (which I could do, but this darn thing worked just fine until the upgrade), is there something I am missing? A configuration perhaps?</p>

<p>Another version that worked (on another site hosted by IIS8.5)</p>

<pre><code>&lt;rewrite&gt;
  &lt;rules&gt;
    &lt;rule name="httpsredirect" stopProcessing="true"&gt;
      &lt;match url="(.*)" /&gt;
      &lt;conditions&gt;
        &lt;add input="{HTTPS}" pattern="off" ignoreCase="true" /&gt;
      &lt;/conditions&gt;
      &lt;action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" /&gt;
    &lt;/rule&gt;
  &lt;/rules&gt;
&lt;/rewrite&gt;
</code></pre>