Share via

Http to HTTPS Redirect we config visual studio 2010

sumit sen 0 Reputation points
2023-12-16T06:29:00.4566667+00:00

my project support visual studio 2010 so, i need help

i want to do Http to Https Redirect in IIs , Please Help

How to do in asp.net old version

thank you

Windows development | Internet Information Services
Developer technologies | ASP.NET Core | Other

1 answer

Sort by: Most helpful
  1. Albert Kallal 5,591 Reputation points
    2023-12-17T18:12:57.19+00:00

    As suggested in comments by SurferOnWww, the rewrite module looks to be a rather nice solution (and is one I use, and in fact I use it to force all URL's on the site to ALWAYS use HTTPS.

    Thus, the choice, the settings, and the re-write rules are NOT part of Visual Studio 2010, or even the 2022 (so version of Visual Studio does not matter).

    What will matter then is the version of IIS your using/deploying to. The re-write module can be found here:

    https://iis-umbraco.azurewebsites.net/downloads/microsoft/url-rewrite

    So, a rule to rewrite (force) the site to always use https, then you could have this rule:

        <system.webServer>
          <rewrite xdt:Transform="Insert">
            <rules>
              <rule name="SSLJUMP" stopProcessing="true"   >
                <match url="(.*)"  />
                <conditions>
                  <add input="{HTTPS}" pattern="^OFF$" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" />
              </rule>
            </rules>
          </rewrite>
        </system.webServer>
    
    

    Do note that after you install the re-write module, then from IIS manager, you should see a new option that allows editing, and creating rules from a nice GUI like this:

    User's image

    So, in the URL Rewrite, then I entered this:

    User's image

    After doing the above, then the web.config changes above was the result.

    Note that I ONLY use/place/have/enjoy the URL writing rules on the production server, since in most cases, one not going to have a valid security certificate during development. So, I ONLY suggest that you use URL rewriting module on the production server, and not say with IIS express during development on your developer computer/setup.

    So, the rewriting rules are setup in IIS, and not really to be setup in Visual Studio. As a result, then using vs2010, or vs2022 should not matter when using the above URL re-writing module.

    Was this answer helpful?

    0 comments No comments

Your answer

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