I recently had the need to start a web server from the command line. Authentication, you see, is a complicated process and sometimes requires you to open a browser to complete that process.
Active Directory, requires you to have a Return Url which isn’t really possible from a command line. Or is it?
With .NET Core, you can easily setup a web server that listens to
localhost. Active Directory, can be configured to redirect to
localhost. Problem solved, right?
Not exactly. I’m partial to not outputing anything to useful when creating a CLI tool. I want kestrel to not output anything in the console. We have other ways to make an EXE talk, you see.
So how do you get Kestrel to go silent?
The first solution led me to change how I built my
WebHost instance by adding
using Microsoft.Extensions.Logging. It is the perfect solution when you want to tell kestrel to not output anything from individual requests.
However, Kestrel will still output that it started a web server and on which ports it’s listening to. Let’s remove that too, shall we?
So next time you need Kestrel to take five, you know what to do. Add that