首页 > 解决方案 > 具有身份验证和预渲染的 Blazor wasm - Google 索引错误

问题描述

我能够为自己构建一个小 blazor wasm 页面,只是因为我喜欢 c#,而且我很高兴有一天能为我的小企业提供一个工作主页......(我对我正在使用的东西知之甚少)在这里,但我一直在挣扎……)

现在页面实际工作了,我添加的最后一件事是预渲染并更改为 _Host 后备。一切似乎都正常,但是当我尝试在谷歌上为我的网站编制索引时,测试工具报告了我网站的索引错误。(见图片)

对于一些想法,我真的很高兴,我不知道这实际上在哪里失败了。我正在使用 .net core 3.1 运行它,包括授权谢谢你的帮助

谷歌错误(sry它的德语)

       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");
        });
    }

标签: .net-coreblazorwebassembly

解决方案


推荐阅读