I have created a new Blazor Server Web App in .Net (the one that has both server and client projects). I would like to use Windows Authentication on this app but I'm not sure how I configure it. In the past I have had Blazor Server apps and run them in IIS under a service account, which worked well. Visual Studio also used my IIS server rather than IIS Express.
But I'm not sure how I configure this on a Blazor Web App or even if its possible?
Previously I would:
Program.cs, add the below:
builder.Services.AddAuthentication(Microsoft.AspNetCore.Server.IISIntegration.IISDefaults.AuthenticationScheme);builder.Services.AddAuthorization();app.UseAuthentication();app.UseAuthorization()Create an application in IIS that pointed to my Blazor Server app.
My Visual Studio launchSettings.json is below
{"$schema": http://json.schemastore.org/launchsettings.json,"iisSettings": {"windowsAuthentication": true,"anonymousAuthentication": false,"iisExpress": {"applicationUrl": http://localhost:46190,"sslPort": 0 } },"profiles": {"http": {"commandName": "Project","dotnetRunMessages": true,"launchBrowser": true,"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}","applicationUrl": http://localhost/OppsSupport,"environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Development" } },"IIS Express": {"commandName": "IISExpress","launchBrowser": true,"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}","environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Development" } } } }But none of this seems to work, I noticed when you create a new Blazer Web App, "Windows" does not appear in the drop down list for authentication.
I get an error of
System.InvalidOperationException: 'A path base can only be configured using IApplicationBuilder.UsePathBase().'
I tried adding the below, but no joy:
app.UsePathBase("/OppsSupport");Any help would be much appreciated.
TIA
UPDATE 1
I managed to get Windows Authentication working via IIS by using the below in my launchsetting.json file:
{"profiles": {"IIS": {"commandName": "IIS","launchBrowser": true,"environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Development" },"applicationUrl": "http://localhost/OppsSupport" } },"$schema": "http://json.schemastore.org/launchsettings.json","iisSettings": {"windowsAuthentication": true,"anonymousAuthentication": false,"iis": {"applicationUrl": "http://localhost/OppsSupport/" } }}However when I now launch my app it loses all CSS and images and when I click a href I get a 404 as it does not remember the virtual directory I'm in.
It goes to http://localhost/counter
Rather than http://localhost/OppsSupport/Counter
Any idea why this happens?