I want to change the default url ( http://localhost:5000 ) when i run the website as a console application .
I edited launchSettings.json but it doesn't work ... it still uses port 5000 :
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:4230/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"website": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:80",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
You need to add the url when you build the "BuildWebHost". Hope this one helps you https://github.com/aspnet/KestrelHttpServer/issues/639
Below is the code I use in my .net core 2.0 console application
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls("http://localhost:5050/")
.Build();
}