Having problems using IIS Express SSL with VS2012

2019-03-12 04:29发布

The Problem:

ADFS2 requires that a RP Trust uses https. The RP trust being https://localhost:44310/PAWS/. With that said, I need to have IIS Express use SSL locally. So, when I configure my ASP.NET MVC4 project to use IIS Express. mvc4 project configuration

When I check this in to TFS (source control) and another developer on the team gets latest. The project will not load for them.

MVC4 project wont load

Visual Studio 2012 will display the following error messages when opening the solution: VS2012 error 1 VS2012 error 2

This is because IIS Express wont automatically read the project file and add the HTTPS binding to the site configuration. This is the configuration that VS adds to IIS Express' applicationhost.config file

<site name="PAWS.Web-Site" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\Users\larsene\Documents\My Web Sites\PAWS.Web-Site14" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:44310:localhost" />
    </bindings>
</site>

But I need it to have the binding protocol set to HTTPS like so:

<binding protocol="https" bindingInformation="*:44310:localhost" />

I can either manually enter that into the applicationhost.config. Or I can run the appcmd.exe like so to configure it.

"%ProgramFiles(x86)%\IIS Express\appcmd.exe" set site /site.name:PAWS.Web-Site /bindings:https/*:44310:localhost

But either of these 2 methods is not what I want. I don't want to have to explain to every developer that works on this project to have to manually edit their IIS Express settings before they can even load the project.

How to recreate the problem:

This is easily re-createable by first closing VS2012. Then deleting the config folder for IIS Express located in

%USERPROFILE%\Documents\IISExpress

and then open VS2012 and also open the solution to the MVC4 project that's configured to use IIS Express with https. Now, VS2012 will fail to load the project and complain about no secure bindings.

What am I doing wrong or how can I fix this so that people who get latest on my project will just be able to run it?

9条回答
我只想做你的唯一
2楼-- · 2019-03-12 05:10

First of all, thank you for providing the steps to reproduce this on your local machine. Other team members were having this issue, but since I created the project, I did not experience it. This allowed me the opportunity to experiment with some different solutions.

What I have found works best in the current environment (no fix from MS) is to leave the project url as the http value, but change the start url to the https value. Most developers should be comfortable changing that in VS.

This works on new machines without requiring someone running a bat file to configure the https site. You do have two bindings in IIS Express (http and https), but other than that, it seems to work well enough.

查看更多
何必那么认真
3楼-- · 2019-03-12 05:18

I can confirm that Visual Studio 2013 is free from this issue.

Upgrading from VS2012 to 2013 solved the problem for me.

查看更多
我想做一个坏孩纸
4楼-- · 2019-03-12 05:25

I see two options:

  • Enable the Apply server setting to all users (store in project file) option on the Web tab to move binding configuration into your project file.

    or

  • Add your project's user file to source control.

    Either approach will allow users to get latest and run without issue.

查看更多
登录 后发表回答