I am writing a CoreWCF PoC and I need to use HTTPS, BasicHttpBinding and Basic Authentication.
It all worked fine until the point when I tried to activate Basic Authentication. So the code below with the Binding that sets ClientCredentialType to 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");
});
throws an Exception on starting up: System.InvalidOperationException: 'Unable to resolve service for type 'Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider' while attempting to activate 'Microsoft.AspNetCore.Authentication.AuthenticationMiddleware'.'
Any idea how can I set up BasicAuthentication in CoreWCF to subsequently read who the logged in user is.
I have reproduced the issue you mentioned. I solve it by downgrading the CoreWCF package version to 1.0.2 or 1.0.1. Other versions (> 1.0.2) have the issue.
My test steps
Tips:
Pay attention to the order when downgrading these two packages, I forgot the specific order, you can try, you can definitely complete the downgrade.