DotnetSparrow
DotnetSparrow

Reputation: 27996

Enabling SSL in asp.net 4.0 and IIS 7.5

I have created an asp.net 4.0 project. I want to enable SSL for it. Do I need to map this web project to new website in IIS. When I try to create a new website, I get:

The binding '*:80:' is assigned to another site. If you assign the same binding to this site, you will only be able to start one of the sites. Are you sure that you want to add this duplicate binding?

I am trying to follow the following posts:

http://weblogs.asp.net/scottgu/archive/2007/04/06/tip-trick-enabling-ssl-on-iis7-using-self-signed-certificates.aspx

http://mscrm4humans.wordpress.com/2010/06/24/enabling-ssl-on-iis-7-0-using-self-signed-certificates/

my IIS is 7.5.7600.... I am totally new to SSL in asp.net. Please suggest solution to this issue.

Upvotes: 0

Views: 10749

Answers (3)

Ira Rainey
Ira Rainey

Reputation: 5209

Whilst it is possible to configure host headers to do what you're after, the easy way is to configure your new site with a different IP address.

Add the new IP address to the server, then setup your binding for the new site to the new IP address on port 80 and 443. Set the app pool to run using .NET 4, then for a nice touch you could add a URLRewrite rule to push all non-SSL traffic to HTTPS by sticking this in your web.config:

<system.webServer>
      <rewrite>
        <rules>
            <rule name="Redirect to HTTPS" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="^OFF$" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

Or if you wanted to force SSL then just tick the Force SSL option in IIS for the site.

Upvotes: 2

Hofma Dresu
Hofma Dresu

Reputation: 432

It sounds like you already have a site setup on port 80. Your IIS probably has a Default Web Site setup. If you're not using that site, you can delete it before you follow the steps in Scott Guthrie's blog post and that should clear up the issue.

If you are using the Default Web Site, change your new site's port to 81 when you create it. You can change the port in the screen shown by the second image in Scott Guthrie's blog post.

If you want to prevent any non-ssl traffic from reaching your new site, you should delete the binding on port 80 (or 81) after you've finished setting everything up.

Upvotes: 1

Sam Huggill
Sam Huggill

Reputation: 3126

To use SSL you must:

  • Have a separate website in IIS
  • This website must have a separate IP address which will be bound on port 443

You cannot use host headers to host separate websites in IIS and use SSL.

Check this article for more help:

http://learn.iis.net/page.aspx/144/how-to-set-up-ssl-on-iis-7/

Upvotes: 0

Related Questions