Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD

Redirect http to https in IIS - Part 102

Suggested Videos
Part 99 - Implementing Enable button to unlock user accounts
Part 100 - Secure Socket Layer in asp.net
Part 101 - Implementing SSL in asp.net web application

In this video we will discuss about redirecting users from HTTP to HTTPS. In the previous session, we discussed about implementing SSL in asp.net. Please watch Part 101, before proceeding with this video.



To redirect users from HTTP to HTTPS automatically, there are several ways. In this video we will discuss about using "url rewrite" module. There are 3 simple steps

Step 1:
Please download and install "URL ReWrite" module from the following link.
http://www.iis.net/downloads/microsoft/url-rewrite

Step 2:
Uncheck "Require SSL" option from "SSL Settings" for the web application in IIS.



Step 3:
Copy and paste the following in the root web.config file of your application.
<system.webServer>
    <httpRedirect enabled="false" destination="" httpResponseStatus="Found" />
    <rewrite>
        <rules>
            <rule name="HTTP to HTTPS Redirection" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="off" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

Now try to navigate to the application using HTTP, you will automatically be redirected to HTTPS.

These rules can also be created in IIS directly using the "URL Rewrite" module

In the next video we will discuss about using "IIS Error Pages" to redirect users from HTTP to HTTPS automatically.

No comments:

Post a Comment

If you like this website, please share with your friends on facebook and Google+ and recommend us on google using the g+1 button on the top right hand corner.