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?
We can use this command to run our host project via Windows Powershell without IIS and visual studio on a separate port. Default of krestel web server is 5001
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.
Change the port Number in json file
All the other answer accounts only for
http
URLs. If the URL ishttps
, then do as follows,Open
launchsettings.json
under Properties of the API project.Change the
sslPort
underiisSettings -> iisExpress
A sample
launchsettings.json
will look as followsUse following one line of code
.UseUrls("http://*:80")
inProgram.cs
Thus changing
.UseStartup<Startup>()
to
.UseStartup<Startup>() .UseUrls("http://*:80")
It's working to me.
I use
Asp.net core 2.2
(this way supported inasp.net core 2.1
and upper version).add
Kestrel
section inappsettings.json
file. like this:and in
Startup.cs
: