1

i was able to build myself a little blazor wasm page, just 'cause i like c# and i would be happy to maybe have a working homepage for my little business sometime... (I know very little about the stuff I'm using right here, but i struggled my way all through...)

Now the page actually works, last thing i added was prerendering and changing to _Host fallback. Everything seems to work, but when i try to index my site on google the test tool reports an indexing error for my site. (see img)

I'd be really glad for some ideas, i got no clues where this actually fails. I'm running this with .net core 3.1 including authorization Thanks for your help

Google Error (sry its german)

       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");
        });
    }
rkits
  • 21
  • 2

0 Answers0