2

I have URL Rewrite rule in IIS 10 to enforce all http request to https this way and it works perfect.

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

Here comes the twist.. I am hosting one ClickOnce application on the same server and when installer try to download the application then it gives error URLDownloadToCacheFile failed with HRESULT '-2146697202' Error: An error occurred trying to download

Although URL is propery accessed via browser which is mentioned in this error.

As per microsoft documents error description is

if the setup URL of the ClickOnce application being installed is redirected from a non-secure to a secure site (or vice-versa), the installation will fail because the Internet Explorer warning interrupts it.

** Installer is using IE internally to download the manifest file

Now to tackle this situation I have made IP binding with my site in IIS so i would access the file with IP but when I do access the site with IP then the above rule also trigger for it and redirects to HTTPS and browser give an error again because hostname mismatch in SSL Certs. I want to bypass this redirect rule for my site when it browsed with IP.

I donot know how I can modify the above rule by having additional condition or what will be the new rule to bypass this https redirection when access via IP.

EDIT: https://dpaste.de/xWJE Here is full webconfig with suggested fix by @Kul Tgin

Arslan Pervaiz
  • 1,575
  • 4
  • 29
  • 62

0 Answers0