.net-core - 具有身份验证和预渲染的 Blazor wasm - Google 索引错误
问题描述
我能够为自己构建一个小 blazor wasm 页面,只是因为我喜欢 c#,而且我很高兴有一天能为我的小企业提供一个工作主页......(我对我正在使用的东西知之甚少)在这里,但我一直在挣扎……)
现在页面实际工作了,我添加的最后一件事是预渲染并更改为 _Host 后备。一切似乎都正常,但是当我尝试在谷歌上为我的网站编制索引时,测试工具报告了我网站的索引错误。(见图片)
对于一些想法,我真的很高兴,我不知道这实际上在哪里失败了。我正在使用 .net core 3.1 运行它,包括授权谢谢你的帮助
public void ConfigureServices(IServiceCollection services)
{
//services.AddDbContext<ApplicationDbContext>(options =>
// options.UseSqlServer(
// Configuration.GetConnectionString("DefaultConnection")));
services.AddDbContext<ApplicationDbContext>(options =>
options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection")));
services.AddDefaultIdentity<ApplicationUser>(options => { options.SignIn.RequireConfirmedAccount = true; })
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddIdentityServer()
.AddApiAuthorization<ApplicationUser, ApplicationDbContext>();
services.AddAuthentication()
.AddIdentityServerJwt();
services.AddTransient<IEmailSender, EMailSender>(i =>
new EMailSender(
Configuration["EmailSender:Host"],
Configuration.GetValue<int>("EmailSender:Port"),
Configuration.GetValue<bool>("EmailSender:EnableSSL"),
Configuration["EmailSender:UserName"],
Configuration["EmailSender:Password"]
)
);
services.AddHsts(options =>
{
options.Preload = true;
options.IncludeSubDomains = true;
options.MaxAge = TimeSpan.FromDays(3);
});
services.AddControllersWithViews();
services.AddRazorPages();
services.AddScoped<HttpClient>(s =>
{
var NavMan = s.GetRequiredService<NavigationManager>();
return new HttpClient { BaseAddress = new Uri(NavMan.BaseUri) };
});
services.AddScoped<AuthenticationStateProvider, ServerAuthenticationStateProvider>();
services.AddScoped<SignOutSessionStateManager>();
Client.Program.ConfigureCommonServices(services);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseWebAssemblyDebugging();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseBlazorFrameworkFiles();
app.UseStaticFiles();
app.UseRouting();
app.UseIdentityServer();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllers();
//endpoints.MapFallbackToFile("index.html");
endpoints.MapFallbackToPage("/_Host");
});
}
解决方案
推荐阅读
- vba - 在 Access 报表上使用 Select 查询
- javascript - Typescript 编译的 Javascript 代码不起作用(variable.default.function())
- javascript - 无法使用 JS 访问 svg 中的元素
- python - 查找列表中的下一个元素
- java - 递归定义中的堆栈溢出错误
- javascript - 如何防止JS中的多个函数调用
- javascript - 尝试在旧版本的 Internet Explorer 中输入输入类型文本时阻止重新加载页面
- mysql - MySQL - 在两列中过滤具有完全相同十进制值的行
- c# - asp.net ListBox 不遵循 Enabled=false;
- mysql - 如何将 latin1_swedish_ci 转换为 utf8-general-ci