I have done the following but it still doesn't work. Running dotnet myapp.dll
still shows it's listening http://localhost:5000.
- Create hosting.json
Code:
{
"server.url": "http://*:5001"
}
- Updated Program.cs
Code:
public class Program
{
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", optional: true, reloadOnChange: true)
.Build();
var host = new WebHostBuilder()
.UseConfiguration(config) // added
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
//.UseUrls("http://*:5001")
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
- Updated project.json
Code:
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config",
"NLog.config",
"hosting.json"
]
You need to change order:
.SetBasePath
should be called before file readingUse
server.urls
, notserver.url