Start API.Net URL

This is mine Program.cs

:

public static void Main(string[] args)
{
    var host = new WebHostBuilder()
        .UseKestrel()
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseUrls("http://localhost:9020")
        .UseIISIntegration()
        .UseStartup<Startup>()
        //.UseApplicationInsights()
        .Build();

    host.Run();
}

      

which was used to work on the port 9020

as mentioned in the section UseUrls()

. For some reason, when I run the program, it gets a message on the port 54033

, and the only thing I think I changed is adding:

<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>

      

for mine .csproj

for release, but I don't see how it will affect the port the service is running on. Is there somewhere else I can check the problem?

+3


source to share


1 answer


In the Properties section of your project, you can find launchSettings.json. Here you can define the profiles in which your application can run. ApplicationUrl sets the url of the application.

enter image description here



Json example:

 "profiles": {
"IIS Express": {
  "commandName": "IISExpress",
  "launchBrowser": true,
  "launchUrl": "api",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  }
},
"RunInCommandPrompt": {
  "commandName": "Project",
  "launchBrowser": true,
  "launchUrl": "api",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  },
  "applicationUrl": "http://localhost:19556"
}
}

      

+4


source







All Articles