Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anders 13 posts 133 karma points
    Jul 09, 2017 @ 18:27
    Anders
    0

    Activated HTTPS, how to access https://localhost?

    Hi :)

    I just activated HTTPS and edited my web.config rules. Build and Deployed, and the online site works perfectly with HTTPS forced.

    <rule name="Redirect to https" stopProcessing="true">
     <match url="(.*)" />
     <conditions>
     <add input="{HTTPS}" pattern="off" ignoreCase="true" />
     </conditions>
     <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
    </rule>
    

    The question is: How can i enable/bypass https on localhost?

    I can't access https://localhost:51713/, which I'm now being redirected to instead of localhost:51713/

    This site can’t provide a secure connection
    
    localhost sent an invalid response.
    Try running Windows Network Diagnostics.
    ERR_SSL_PROTOCOL_ERROR
    

    Thanks in advance,

    / Anders

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Jul 09, 2017 @ 21:08
    Dan Diplo
    100

    If you're using visual studio and local IIS then there's an option to enable HTTPS in it - see http://dailydotnettips.com/2014/01/27/enabling-ssl-with-iis-express-in-visual-studio/

    If you're using full IIS on local machine you could probably create a self-signed certificate.

    Otherwise if you just wish to bypass then check this answer on StackOverflow: https://stackoverflow.com/questions/20947773/rewrite-rule-to-https-except-when-on-localhost

  • Anders 13 posts 133 karma points
    Jul 10, 2017 @ 18:51
    Anders
    0

    Hi Dan

    Thanks for answering my question.

    I couldn't fint the settings in Visual Studio, where I could enable HTTPS, as you mentioned in your first solution.

    But your last solution led me to another stackoverflow solution that did the trick.

    Here is my end result:

    <rule name="Redirect to https" enabled="true" stopProcessing="true">
       <match url="(.*)" />
       <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
          <add input="{HTTPS}" pattern="off" />
          <add input="{HTTP_HOST}" pattern="localhost" negate="true" />
       </conditions>
       <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
    </rule>
    
  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Jul 10, 2017 @ 20:28
    Dan Diplo
    0

    Nice, glad you got there in the end! I'm going to make a note of that :)

    Strange you couldn't find it in VS - it's in my 2015 and 2017 editions.

Please Sign in or register to post replies

Write your reply to:

Draft