【发布时间】:2021-10-18 07:37:28
【问题描述】:
我刚刚使用身份验证项目创建了 Blazor WebAssembly,并没有更改代码上的任何内容,然后尝试在 Windows IIS 上托管该项目,当网站运行时它总是给我这个错误:
("crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Could not load settings from '_configuration/MyWebstieAut.Client'
Error: Could not load settings from '_configuration/MyWebstieAut.Client'
at a.createUserManager (http://mywebsiteaut.com/_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js:1:5887)
at Generator.prototype.next (native code)
Microsoft.JSInterop.JSException: Could not load settings from '_configuration/MyWebstieAut.Client'
Error: Could not load settings from '_configuration/MyWebstieAut.Client'
at a.createUserManager (http://mywebsiteaut.com/_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js:1:5887)
at Generator.prototype.next (native code)
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <0x21bcc70 + 0x0002c> in <filename unknown>:0
at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsyn")
你能帮帮我吗?
谢谢
program.cs:
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.Services.AddHttpClient("{ProjectName}.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))
.AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
// Supply HttpClient instances that include access tokens when making requests to the server project
builder.Services.AddScoped(sp => sp.GetRequiredService<IHttpClientFactory>().CreateClient("{ProjectName}.ServerAPI"));
builder.Services.AddApiAuthorization();
await builder.Build().RunAsync();
appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-{ProjectName}.Server-A5A9DCDA-10E3-45AE-A34F-DEF0D6A04784;Trusted_Connection=True;MultipleActiveResultSets=true",
"{ProjectName}ServerContextConnection": "Server=(localdb)\\mssqllocaldb;Database={ProjectName}.Server;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"IdentityServer": {
"Clients": {
"{ProjectName}.Client": {
"Profile": "IdentityServerSPA"
},
"Key": {
"Type": "Store",
"StoreName": "WebHosting",
"StoreLocation": "CurrentUser",
"Name": "CN=MyApplication"
}
}
},
"AllowedHosts": "*"
}
【问题讨论】:
标签: authentication blazor blazor-webassembly