Localhost SSL vb sites

nickCroat 111 Reputation points
2022-08-30T13:30:46.74+00:00

Hi,

I am using Visual studio 2022 and I just can't open any site from visual studio because I am getting error:
This site can’t provide a secure connectionlocalhost sent an invalid response.
Try running Windows Network Diagnostics.
ERR_SSL_PROTOCOL_ERROR

I have in vb code shown below in web.config:
<system. Webserver>
<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>
</system. Webserver>

Is there really nothing Microsoft can do about this?

Developer technologies Visual Studio Debugging
Developer technologies VB
{count} votes

Accepted answer
  1. Michael Taylor 60,161 Reputation points
    2022-08-30T14:28:11.46+00:00

    Your redirect rule seems reasonable although the condition should probably be the simpler.

       <conditions>  
         <add input="{HTTPS}" pattern="^OFF$" />  
       </conditions>  
    

    However you have made the redirect permanent (301) and this is almost always the wrong value. It tells browsers that the redirect is permanent and therefore don't bother asking again. In many cases this means the browser isn't ever going back to the original URL even if the user types it in. It'll just autoredirect to the new URL. Especially when you're testing your redirect rules this will permanently mangle things as your redirect rule is no longer used. You should leave it as temporary (302). Temporary tells the browser to check again later. I suspect at this point that your browser is permanently going to the URL that you originally configured as permanent and that may not be what you're using now.

    If you are in this state then here is a link to how to "reset" it in Chrome.

    VS has no issues with HTTP to HTTPS redirects and debugging. It works just fine. To save some time ensure your app's startup URL is configured for the HTTPS protocol though. If you're running IISX then you should be able to bring up the properties window (F4) of VS, select the project in Solution Explorer and see the option to enable SSL.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.