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"
}
}
}
}
Once you open the project properties window, click on the “Debug” tab on the as shown in the below image. Using the Graphical User Interface, you can also change the settings of the launchSettings. json file. Now here you can see that the Environment Variable “ASPNETCORE_ENVIRONMENT” is set to “Development”.
If you create a new project in Visual Studio you can get some boilerplate code for your launchSettings.json file (found at /Properties/launchSettings.json in your project), which will look like the following: { "$schema": "http://json.schemastore.org/launchsettings.json", "iisSettings": { "windowsAuthentication": false ...
launchSettings. json, which is placed in the Properties folder of a project, describes how the application can be launched — the command to execute, whether the browser should be opened, which environment variables should be set, and so on.
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();
}
Screenshot of the console output
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