我正在撰寫 CoreWCF PoC,我需要使用 HTTPS、BasicHttpBinding 和 Basic Authentication。
在我嘗試激活基本身份驗證之前,一切都很好。因此,下面帶有將 ClientCredentialType 設定為 HttpClientCredentialType.Basic 的系結的代碼:
var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
var app = builder.Build();
app.UseServiceModel(builder =>
{
// Add service with a BasicHttpBinding at a specific endpoint
builder.AddService<DownloadService>((serviceOptions) => {
serviceOptions.DebugBehavior.IncludeExceptionDetailInFaults = true;
}).AddServiceEndpoint<DownloadService, IDownloadService>(basicHttpBinding, "/DownloadService/basichttp");
});
啟動時拋出例外:System.InvalidOperationException:“嘗試激活‘Microsoft.AspNetCore.Authentication.AuthenticationMiddleware’時無法決議型別‘Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider’的服務。”
知道如何在 CoreWCF 中設定 BasicAuthentication 以隨后讀取登錄用戶是誰。
uj5u.com熱心網友回復:
你提到的問題我已經復現了。我通過將 corewcf 包版本升級到 1.0.2 或 1.0.1 來解決它。其他版本(> 1.0.2)有問題。

我的測驗步驟

提示:
降級這兩個包要注意順序,具體順序忘記了,你可以試試,肯定可以完成降級的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/536493.html
標籤:asp.net-核心验证基本认证基本的http绑定corewcf
