Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core: How to change IIS Express port?

Tags:

asp.net-core

I'm using IIS Express to host my website and API both of which are ASP.NET Core apps. When I look at my HTTP network logs using Fiddler, I always forget what port belongs to which app. To solve this, I would like to change the port number that my apps currently use to a number that is more memorable.

For example, I want my UI website to use port 50000 and my internal API to use 50001.

Intuition tells me to change the "sslPort" and "launchUrl" to 50000 and 50001 respectively but that doesn't work.

For example, this is my current launchSettings.json file for my ASP.NET

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iis": {
      "applicationUrl": "http://localhost",
      "sslPort": 0
    },
    "iisExpress": {
      "applicationUrl": "http://localhost:29751",
      "sslPort": 44371
    }
  },
  "profiles": {
    "Development": {
      "commandName": "IISExpress",
      "launchUrl": "https://localhost:44371/"
    }
  }
} 

Changing it to this doesn't work

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iis": {
      "applicationUrl": "http://localhost",
      "sslPort": 0
    },
    "iisExpress": {
      "applicationUrl": "http://localhost:29751",
      "sslPort": 50000
    }
  },
  "profiles": {
    "Development": {
      "commandName": "IISExpress",
      "launchUrl": "https://localhost:50000/"
    }
  }
} 

Question: Why doesn't this change work? How do I change the port number?

Many thanks...

like image 736
burnt1ce Avatar asked Aug 11 '18 15:08

burnt1ce


People also ask

How do I change the port in .NET core?

To change the port the application is using, Open the file lunchSetting. json. You will find it under the properties folder in your project and as shown below. Inside the file, change applicationUrl port (below is set to 5000) to a different port number and save the file.

What port does IIS Express use?

By default IIS Express uses port 8080, but you can use any HTTP port you like. You can also run these from the WIndows Command line in the Web Connection install folder by running Console.exe .

How can I change port number in asp net?

In Solution Explorer, click the name of the application. In the Properties pane, click the down-arrow beside Use dynamic ports and select False from the dropdown list. This will enable editing of the Port number property. In the Properties pane, click the text box beside Port number and type in a port number.


1 Answers

I found the solution. When changing the SSL port number, it must be within 44300 - 44399 otherwise it won't work. Reference: developercommunity.visualstudio.com/comments/43139/view.html. @Tseng, please remove the "duplicate" flag

like image 145
burnt1ce Avatar answered Oct 13 '22 01:10

burnt1ce