Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2015 / IISExpress change SSL port

I have 2 projects, a Web API and a client angularJS project (that was created using the Empty Project template). My client has asked me to force SSL, so for the Web API I created a filterAttribute. Anyway, I changed both projects to be SSL Enabled. The problem is, both projects show their SSL URL to be http://localhost:44300 which obviously won't work.

So I decided to change the applicationhost.config file. For Visual Studio 2015, this appears to be in the .vs folder. When I change it in there, if I open my project it overwrites it and puts it back to 44300.

I tried creating a virtual directory (in the properties of my API) and I tried to override the application root URL. Neither worked.

Does anyone know how I can use a different SSL port?

like image 986
r3plica Avatar asked Sep 29 '15 09:09

r3plica


People also ask

How do I change my port number for VS 2015?

In Solution Explorer, click the name of the site. In the Project menu, click Properties. Click the Web tab. Click Specific port and enter a port number.

How do I change the port for IIS Express?

In Solution Explorer, right-click the name of the application and then select Properties. Click the Web tab. In the Servers section, under Use Local IIS Web server, in the Project URL box change the port number. To the right of the Project URL box, click Create Virtual Directory, and then click OK.


2 Answers

I had the same situation with 2 projects. Visual Studio 2015 correctly assigned differing URL port numbers for HTTP but mapped both projects to 44300 for HTTPS.

AFAIK the applicationhost.config in .vs\config seems to define the IIS Express environment and tell IIS Express how to behave when invoked. This information doesn't feedback into Visual Studio.

Visual Studio appears to rely on settings in the .csproj file. This is the SSL port value you see when you look at properties for the project in VS.

I was able untangle the two projects by adjusting both:

  1. Changing the IISExpressSSLPort value in my project's .csproj file
  2. I also needed to ensure that the https binding was included in the applicationhost.config

.csproj

<UseIISExpress>true</UseIISExpress> <IISExpressSSLPort>44301</IISExpressSSLPort> 

applicationhost.config

<bindings>    <binding protocol="http" bindingInformation="*:58001:localhost" />    <binding protocol="https" bindingInformation="*:44301:localhost" /> </bindings> 

Update:

The file .csproj.user also has SSL Port configuration, to avoid the overwriting of the SSL port number in the applicationhost.config file, .csproj.user should be updated too.

<UseIISExpress>true</UseIISExpress> <IISExpressSSLPort>44301</IISExpressSSLPort> 
like image 69
Greg Terrell Avatar answered Sep 20 '22 13:09

Greg Terrell


For Asp.Net Core see "/Properties/launchSettings.json" file.

like image 22
Skorunka František Avatar answered Sep 21 '22 13:09

Skorunka František