我在Visual Studio 2015中有一个相同的问题。因为我在web.config中使用SSL绑定
<rewrite>
<rules>
<rule name="HTTP to HTTPS Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
</rule>
</rules>
</rewrite>
我可以用djroedger先生的答案解决问题。通过更换
<add input="{HTTPS}" pattern="off" />
与
<add input="{HTTP_HOST}" pattern="localhost" negate="true" />
进入我的web.config,所以我的代码是
<rewrite>
<rules>
<rule name="HTTP to HTTPS Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="localhost" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
</rule>
</rules>
</rewrite>