Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the port number for Asp.Net core app?

I added the following section in project.json.

  "commands": {     "run": "run server.urls=http://localhost:8082",     "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:8082",     "weblistener": "Microsoft.AspNet.Hosting --server WebListener --server.urls http://localhost:8082"   }, 

However, it still shows "Now listening on: http://localhost:5000" when run it using dotnet myapp.dll?

BTW, will clients from other machine be able to access the service?

like image 681
ca9163d9 Avatar asked Aug 04 '16 00:08

ca9163d9


People also ask

How do I change the port number in NET Core app?

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 is port number in asp net?

We know that ASP.NET Core Application runs under Kestrel Server with default port number http://localhost:5000.

How do I change the port for .NET 6?

From source codeClick on the Dropdown on the run button. Now click on debug properties. By clicking on that launch profile window will open. now you can change the port from the app URL from here.

How do I change the default port number in ASP NET?

To specify a port for the ASP.NET Development Server 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.

How to change the port in an ASP NET Core web API?

How to Change the Port in an ASP.NET Core Web API March 22, 2019 Leave a comment To change the port in an ASP.NET Web API, under Properties go to the launchSettings.json file. In this case, let’s change the IIS default SSL port.

How to change the port number of a web app?

In Asp.net core 2.0 WebApp, if you are using visual studio search LaunchSettings.json. I am adding my LaunchSettings.json, you can change port no as u can see. In visual studio 2017 we can change the port number from LaunchSetting.json In Properties-> LaunchSettings.json. Open LaunchSettings.json and change the Port Number.

How do I change the port number of my project?

To change the port number, I right click on my project -> Properties From the application properties screen, I will click on Debug under the Web Server Settings I will change the port number next to APP URL. For example is the port number is set to 54327 as configured as http://localhost:54327 I will simply change the port number.


1 Answers

Yes this will be accesible from other machines if you bind on any external IP address. For example binding to http://*:80 . Note that binding to http://localhost:80 will only bind on 127.0.0.1 interface and therefore will not be accesible from other machines.

Visual Studio is overriding your port. You can change VS port editing this file Properties\launchSettings.json or else set it by code:

        var host = new WebHostBuilder()             .UseKestrel()             .UseContentRoot(Directory.GetCurrentDirectory())             .UseIISIntegration()             .UseStartup<Startup>()             .UseUrls("http://localhost:80") // <-----             .Build();          host.Run(); 

A step by step guide using an external config file is available here.

like image 165
Gerardo Grignoli Avatar answered Oct 03 '22 05:10

Gerardo Grignoli