Was struggling really hard with getting this command to work:
dotnet run -- --server.urls http://*:5000
Simple command, but it isn’t taking! Well I missed one major thing when upgrading from RC1 to RC2, I need to now pass configuration down to the Kestrel stack, to do that is pretty easy:
public static void Main(string[] args) { var config = new ConfigurationBuilder() .AddCommandLine(args) .AddEnvironmentVariables(prefix: "ASPNETCORE_") .Build(); var host = new WebHostBuilder() .UseConfiguration(config) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); }
Needed to define the “config” variable and pass it to WebHostBuilder using UseConfiguration(). All fixed!
Hey there, I was wondering where I could find the command-line documentation for ” dotnet myproject.dll –sever.urls”.
I’am running across code examples that use “–urls” instead of “–server.urls”.
Are these shorthand and longhand versions of the same parameter?
`-urls` is likely shorthand, at least in my experience one dash == shorthand.
According to comments in the source `–server.urls` is mapped to the UseUrl() method. That’s all I’ve seen in relation to the subject: https://github.com/aspnet/KestrelHttpServer/blob/2351c1b558fc6f4312af262aa866fd2c5164761f/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServerOptions.cs#L19
But if the shorthand works, I don’t see any reason you can’t use it.