Search code examples
asp.nethttpsurl-rewritingweb-configweb.config-transform

Automatically redirects my application from HTTP to HTTPS in Google Chrome Browser


I added the below code in web.config, for forwarding the URL from HTTP to HTTPS.

 <rewrite xdt:Transform="Insert">
  <rules>
    <!-- Redirects users to HTTPS if they try to access with HTTP -->
    <rule
      name="Force HTTPS"
      stopProcessing="true">
      <match url="(.*)"/>
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$" ignoreCase="true"/>
      </conditions>
      <action
        type="Redirect"
        url="https://{HTTP_HOST}/{R:1}"
       /> <!--redirectType="Permanent"-->
    </rule>
  </rules>

</rewrite>

It's working fine, after some time I removed the above code from web.config but still my Google Chrome browser will automatically redirects my URL form http to https whenever my application runs in my local machine.


Solution

  • Google Chrome caches redirects. Clear cache after making changes to web config or at least keep developer console opened with "Disable cache" options checked in the Network tab.