Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net Core change url in launchSettings.json not working

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"
      }
    }
  }
}
like image 995
F Andrei Avatar asked Jul 11 '16 19:07

F Andrei


People also ask

How do I change JSON launchSettings?

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”.

What is launch URL in launchSettings JSON?

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 ...

How does launchSettings JSON work?

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.


1 Answers

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

like image 108
Charan Avatar answered Sep 28 '22 11:09

Charan