On .Net Core 3.1 just follow Microsoft Doc that it is pretty simple: kestrel-aspnetcore-3.1
To summarize:
Add the below ConfigureServices section to CreateDefaultBuilder on Program.cs
:
// using Microsoft.Extensions.DependencyInjection;
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((context, services) =>
{
services.Configure<KestrelServerOptions>(
context.Configuration.GetSection("Kestrel"));
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
Add the below basic config to appsettings.json
file (more config options on Microsoft article):
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://0.0.0.0:5002"
}
}
}
Open CMD or Console on your project Publish/Debug/Release binaries folder and run:
dotnet YourProject.dll
Enjoy exploring your site/api at your http://localhost:5002