Using appsettings.json to configure Kestrel listen port Dotnet core 2 preview 2

As mentioned in a comment on the accepted answer, 2.1 has support for appsettings.json, see https://blogs.msdn.microsoft.com/webdev/2018/02/02/asp-net-core-2-1-roadmap/#security A working appsettings.json: “Kestrel”: { “EndPoints”: { “Http”: { “Url”: “http://localhost:5555″ } } } This is for a Program.cs using (created by “dotnet new webapi”): WebHost.CreateDefaultBuilder(args) Relevant source code in GitHub https://github.com/aspnet/MetaPackages/blob/master/src/Microsoft.AspNetCore/WebHost.cs#L163 options.Configure(builderContext.Configuration.GetSection(“Kestrel”)); and https://github.com/aspnet/MetaPackages/blob/master/src/Microsoft.AspNetCore/WebHost.cs#L169 config.AddJsonFile(“appsettings.json”, optional: true, reloadOnChange: … Read more

Access environment name in Program.Main in ASP.NET Core

I think the easiest solution is to read the value from the ASPNETCORE_ENVIRONMENT environment variable and compare it with Environments.Development: var environment = Environment.GetEnvironmentVariable(“ASPNETCORE_ENVIRONMENT”); var isDevelopment = environment == Environments.Development; .NET 6 or higher Starting from .NET 6 using the new application bootstrapping model you can access the environment from the application builder: var builder … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)