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?
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.
We know that ASP.NET Core Application runs under Kestrel Server with default port number http://localhost:5000.
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.
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 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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With