React to recent changes and use a new UseWhen extension to enable conditional middleware execution

https://github.com/aspnet/Hosting/commit/b44ffdb745aa227b311a6f0ec3d178db33fd8c70