Visual Studio 2015 / IISExpress change SSL port

33,986

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:

  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>

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.

Share:
33,986
r3plica
Author by

r3plica

SOreadytohelp

Updated on July 09, 2022

Comments

  • r3plica
    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
    CamHart over 8 years
    I found modifying the .csproj file was sufficient. VS appears to rewrite applicationhost.config using my projects current configuration.
  • r3plica
    r3plica over 8 years
    I will give this a test because I never found the solution :)
  • RayLoveless
    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
    Marc van Nieuwenhuijzen over 7 years
    I changed this, but my values in VS are still overwritten with the old portnumber
  • chrismay
    chrismay over 7 years
    In 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
    nmit026 about 7 years
    This 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
    Greg Terrell almost 7 years
    I 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
    Codendaal over 4 years
    The real MVP! Not sure why the "applicationhost.config" has got an entry, but mine only used the value from "launchSettings.json"
  • Jay Jay Jay
    Jay Jay Jay over 4 years
    Had 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
    ibrahimozgon over 4 years
    worked for me. I have a problem with .csproj.user file. Thank you.
  • Hector S.
    Hector S. over 3 years
    To @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
    CarComp over 3 years
    Wow. 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
    Fordy about 3 years
    But 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.