Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode launch ASP.NET Core app on a specific port

Tags:

From launch.json, what is the correct way to launch an ASP.NET Core on a specific port? For instance, when I run my .NET Core app, VS Code, hosts it on localhost:5000, but I instead want to host it on localhost:5050.

Thanks in advance.

like image 641
Tyson Nero Avatar asked Oct 10 '16 00:10

Tyson Nero


People also ask

How do I change the port number of a .NET Core application?

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.

How do I run a .NET Core app in VS Code?

You can run an ASP.NET Core application from Visual Studio Code directly. To accomplish this, open the Command Palette, type dnx and press Enter. Next, select dnx: Run Command and press Enter.

How do I change the port in VS Code?

Yes, we can change live server port in vs code as per out choice. This can be very easily done by the following ways, Open up live server extension > Go to it's Extension Settings > Open up settings. json > Change the port.

How do I change the localhost port in Visual Studio?

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


1 Answers

You can config it via environment variable ASPNETCORE_URLS

macOS:

export ASPNETCORE_URLS=http://localhost:5050 

windows:

set ASPNETCORE_URLS=http://localhost:5050 

or add this to launch.json

  "env": {     "ASPNETCORE_URLS": "http://localhost:5050"   } 

If you don't want to specify the hostname, you can use * instead

http://*:5050 
like image 125
Takahiro Avatar answered Oct 23 '22 01:10

Takahiro