Having problems using IIS Express SSL with VS2012 and a Team

白昼怎懂夜的黑 提交于 2019-12-02 22:24:00

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

Upgrading from VS2012 to 2013 solved the problem for me.

I have recently come across this same problem, and I've been able to determine why it's happening.

Visual Studio is using the Project Url setting to set the IIS Express http binding, and then it looks at the IISExpressSSLPort setting to set the https binding.

However, if you've changed the Project Url to an https address, that is when Visual Studio gets confused. For the purposes of IIS Express binding updating, it assumes that you've entered an http address for the Project Url and doesn't seem to be able to handle an https address being there.

This complicates things since changing the Project Url to an https address is the only way I've found to make Visual Studio start debugging the https url by default.

So, this seems to be a problem in how Visual Studio is handling the IIS Express binding updates. I'm not aware of a good workaround that allows both the automated binding updates and to start debugging with the https address loaded.

This looks like it might be a bug in VS2012... The only way I've been able to handle this is by hand editing the IISExpress configuration file: applicationhost.config, located under C:\Users\YOUR_USER_NAME\Documents\IISExpress\config. Then under 'sites' I modified the block for the specific application's website:

    <site name="YourSite" id="1">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="c:\..." />
            </application>
            <bindings>
                <binding protocol="https" bindingInformation="*:YOUR_PORT_#:localhost" />
            </bindings>
    </site>

Change the 'binding protocol' to 'https' and make sure you start Visual Studio 2012 with Admin privileges, at least until the site is created/modified in IIS Express.

Hope this helps...

You need to set SSL Enabled to True in the project's properties list in order to have that binding show up automatically. (per Scott Hanselman)

Have you tried opening the project as an admin (run VS2012 as an administrator)?

Usually when you get the above errors (configuring web xxx for ASP.NET 4.5 failed...) and (creation of the virtual directory xxx failed) is because visual studio does not have enough privileges.

May not be your problem, but it doesn't hurt to try.

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.

Have you tried to manually configure the port in the .csproj file? Once you've configured it there, it should carry over to other workstations:

<IISExpressSSLPort>44310</IISExpressSSLPort>

Also, the project's user file can still cause issues even with the "Apply server settings to all users" option checked. I normally just delete the user file when I fix SSL issues with IIS Express, because it's much easier to just reconfigure my user settings after I've fixed my issue.

I have recently had a very similar issue and came across this post when trying to resolve. One thing I have noticed is that IIS Express seems to get very distressed if more than one site is set up with a HTTPS binding in the applicationhost.config file.

In my case, I had 2 sites set up to use the same SSL binding to port 44300, changing the port number on one of the SSL bindings on one of the sites caused errors similar to the ones in the OP. I ended up having to remove one of the sites, which is not ideal.

After a little more digging, I tried toggling the 'Require SSL' property from true to false, and back to true. This triggered an update the applicationhost.config which created a new SSL binding with a new port number.

I got into this mess because I had copied an existing project and my config was trying to share ports between 2 sites.

Sean O'Brien

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.

I recently had a very similar problem with VS 2019 and IIS Epress. I tried to change the http to https so that I could use ADFS. Ce site est inaccessible localhost n'autorise pas la connexion.

After a little more research, I tried to switch the 'Require SSL' property from true to false and back to true. This triggered an update to the applicationhost.config file (... . Vs \ ProjectName \ config \ applicationhost.config) that created a new SSL binding with a new port number for the https protocol. So, I modified all the links with the proposed new port (in the web property of the project, the config file and the ADFS config) and it works. Conclusion, it is not necessary that the http port is the same as https same for the same site.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!