Visual Studio 2015 / IISExpress change SSL port
Solution 1
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:
- Changing the IISExpressSSLPort value in my project's .csproj file
- 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>
Solution 2
For Asp.Net Core see "/Properties/launchSettings.json" file.
Solution 3
For vs2015, I found the file applicationhost.config with the correct content under the .vs\ folder in my solution.
Comments
-
r3plica almost 2 years
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?
-
CamHart over 8 yearsI found modifying the .csproj file was sufficient. VS appears to rewrite applicationhost.config using my projects current configuration.
-
r3plica over 8 yearsI will give this a test because I never found the solution :)
-
RayLoveless over 7 years@Dani, you have to view the file from the File explorer. Visual studio won't show that file by default.
-
Marc van Nieuwenhuijzen over 7 yearsI changed this, but my values in VS are still overwritten with the old portnumber
-
chrismay over 7 yearsIn case anyone else has this isuse, I also found the file there, but changes to it are ignored. If I change the port in the <binding> then the next time I hope the project it creates a whole new <site> block and ignores everything I've done.
-
nmit026 about 7 yearsThis worked for me, but only HTTP works, not HTTPS. The HTTPS port I'm trying to use is is 8443 but the browser won't connect. In Chrome it says: "This site can’t be reached.The connection was reset." Any ideas? Been struggling with this all day. The HTTP port is 8080.
-
Greg Terrell almost 7 yearsI believe that the "standard" IIS Express functionality only allows for SSL ports of 44300 to 44399. I have seen posts that describe how to make IIS Express work outside that range, but that wasn't a big deal for me to stay within those 100 addresses.
-
Codendaal over 4 yearsThe real MVP! Not sure why the "applicationhost.config" has got an entry, but mine only used the value from "launchSettings.json"
-
Jay Jay Jay over 4 yearsHad search through the folders to find this. Just do a search across the solution folder for the currently mapped port number to find which file you have to modify to set the new port number.
-
ibrahimozgon over 4 yearsworked for me. I have a problem with .csproj.user file. Thank you.
-
Hector S. over 3 yearsTo @GregTerrell's point, here is the documentation for the custom ports: docs.microsoft.com/en-us/iis/extensions/using-iis-express/…. I was not able to get it working and is too much setup for us so we are just going to use one of the default ports for now. I wish this range was not necessary.
-
CarComp over 3 yearsWow. Just wow. This is the answer we need. Also, if you want to use SSL, don't use it with IISExpress, use "Project" and put the app url to
https://localhost:443;http://localhost:80
-
Fordy about 3 yearsBut if you are using IISExpress, it appears SSL ports must be in the range 44300 to 44399. If you choose something outside this range you will get a "This site can't be reached" or similar blank page.