我能够为自己建立一个小小的wasm页面,只是因为我喜欢c#,所以我很乐意在某个时候为我的小企业提供一个工作的主页... (我对我现在在这里使用的东西知之甚少,但是我一直在努力挣扎……)
现在该页面实际可用,我添加的最后一件事是预渲染并更改为_Host fallback。 一切似乎都正常,但是当我尝试在Google上为我的网站建立索引时,测试工具会报告我的网站出现索引错误。 (请参见img)
我为某些想法感到非常高兴,但我不知道这实际上失败了。 我正在使用包含授权的.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");
});
}