2016-02-12 62 views
1

我想在IIS下使用WebListener服務託管ASP.NET Core應用程序,並試圖讓它使用Windows身份驗證。但是,如果爲我的「web」命令指定了WebListener,並且在IIS下部署和設置了應用程序,則會收到502響應,並顯示消息「Web服務器在充當網關或代理服務器時收到無效響應」。如何讓我的ASP.NET核心應用程序使用WebListener和Windows身份驗證在IIS下託管?

我能夠在IIS下使用Kestrel成功託管應用程序,但不幸的是Kestrel不支持NTLM(或者至少這是我閱讀和經歷的)。

所以,我正在尋找一種方式來:

  • 獲取應用程序使用WebListener代替紅隼工作,並
  • 讓它使用Windows身份驗證

這項工作所有在本地使用web命令(即在Visual Studio中運行)的本地工作。它只是在IIS下的WebListener中不起作用。

我安裝了最新的HttpPlatformHandler(1.2)。 我有forwardWindowsAuthToken設置爲true。 我在配置中禁用了AnonymousAuthentication並啓用了WindowsAuthentication。 我的目標是1.0.0-rc1-update1

下面是一些配置代碼在我Startup.cs文件:

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<WebListener>(); 
    if (listener != null) 
    { 
     listener.AuthenticationManager.AuthenticationSchemes = 
      AuthenticationSchemes.NTLM; 
    } 
} 

任何幫助將不勝感激。感謝您抽時間閱讀。

+0

是否有任何這項工作:http://stackoverflow.com/questions/28542141/windows-authentication-in-asp-net-5 –

+1

謝謝肖恩,但不,不幸的是,它不工作。奇怪的是,我可以在本地運行web命令以使用WebListener進行自主宿主。但嘗試在IIS中託管它不起作用 - 沒有任何請求被解決。 – slade73

回答

1

HttpPlatformHandler不支持WebListener,所以我不認爲你將能夠實現你想要的。查看github上的this thread瞭解更多詳情。

+0

謝謝帕維爾! – slade73

相關問題