How Do I Get My ASP.NET Core Application To Host Under IIS Using WebListener and Windows Authentication?
<p>I'm trying to host an ASP.NET Core application under IIS using the WebListener service, and am trying to get it to make use of Windows Authentication. However, when WebListener is specified for my "web" command, and the application is deployed and set up under IIS, I get a 502 response with the message "Web server received an invalid response while acting as a gateway or proxy server."</p>

<p>I'm able to successfully host the application using Kestrel under IIS, but unfortunately Kestrel doesn't support NTLM (or at least that's what I've read and experienced).</p>

<p>So, I'm looking for a way to:</p>

<ul>
<li>Get the application to work using WebListener instead of Kestrel, and</li>
<li>Get it to work with Windows Authentication</li>
</ul>

<p>This all works locally when using the web command locally (i.e. running it in Visual Studio). It just doesn't work from WebListener under IIS.</p>

<p>I have the latest HttpPlatformHandler installed (1.2).
I have the <strong>forwardWindowsAuthToken</strong> setting set to <strong>true</strong>.
I have AnonymousAuthentication disabled and WindowsAuthentication enabled in config.
I am targeting <strong>1.0.0-rc1-update1</strong>.</p>

<p>Here is some of the configuration code in my Startup.cs file:</p>

<pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseIISPlatformHandler();

    SetupWindowsAuthForLocalDev(app);

    app.UseMvc();
    app.UseDefaultFiles();
    app.UseStaticFiles();
    app.UseDeveloperExceptionPage();

    app.UseRuntimeInfoPage();

    app.UseAutoMapper();
    app.ConfigureStorageAccountForCors(_config);

    loggerFactory.AddSerilog();
}


private static void SetupWindowsAuthForLocalDev(IApplicationBuilder app)
{

    var listener = app.ServerFeatures.Get&lt;WebListener&gt;();
    if (listener != null)
    {
        listener.AuthenticationManager.AuthenticationSchemes =
            AuthenticationSchemes.NTLM;
    }
}
</code></pre>

<p>Any help would be greatly appreciated. Thanks for taking the time to read this.</p>