Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

MudBlazor LoginForm not working in .NET 8, MudBlazor 8.6.0

$
0
0

So I'm completely new to .NET/C# and I'm trying to build a simple web-app connected to a database.Somehow I just can't get it to work with MudBlazor:

Problem:

  1. When I input text into my LoginForm, the userinput overlaps with the Labels:enter image description here
  2. When I click the Login Button, nothing happens. The SubmitForm() method is not being called, but the code is so simple, it should work: code snippet

I have tried changing a lot of stuff in my configurations but couldn't get it to work.If you need more information, you can find the project here. (You can also run it yourself in a docker container by using the build_and_deploy script)

Maybe there is something wrong in my Program.cs?

using Microsoft.AspNetCore.Authentication.Cookies;using Microsoft.AspNetCore.Authorization;using Microsoft.AspNetCore.Components.Authorization;using Microsoft.EntityFrameworkCore;using MudBlazor.Services;using PortfolioWebApp.Components;using PortfolioWebApp.Models;using PortfolioWebApp.Services;var builder = WebApplication.CreateBuilder(args);builder.Services.AddRazorComponents()    .AddInteractiveServerComponents();builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)    .AddCookie(options =>    {        options.Cookie.Name = "auth_cookie";        options.LoginPath = "/Account/Login";        options.AccessDeniedPath = "/Error/Forbidden";        options.ExpireTimeSpan = TimeSpan.FromMinutes(30);        options.Cookie.SecurePolicy = CookieSecurePolicy.Always;        options.Cookie.SameSite = SameSiteMode.Strict;    });builder.Services.AddAuthorization(options => {    options.FallbackPolicy = new AuthorizationPolicyBuilder()        .RequireAuthenticatedUser()        .Build();});builder.Services.AddHttpContextAccessor();builder.Services.AddScoped<AuthenticationStateProvider, CustomAuthenticationStateProvider>();builder.Services.AddScoped<CustomAuthenticationStateProvider>();builder.Services.AddCascadingAuthenticationState();builder.Services.AddMudServices();builder.Services.AddDbContext<AppDbContext>(options =>     options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));builder.Services.AddScoped<IPasswordHashingService, PasswordHashingService>();builder.Services.AddScoped<IUserRegistrationService, UserRegistrationService>();builder.Services.AddScoped<IUserLoginService, UserLoginService>();/*builder.Services.AddAntiforgery(options => {    options.HeaderName = "X-CSRF-TOKEN";    options.Cookie.Name = "X-CSRF-TOKEN";    options.SuppressXFrameOptionsHeader = false;}); */var app = builder.Build();app.UseExceptionHandler("/Error/ServerError");app.UseStatusCodePagesWithReExecute("/error/{0}");if (!app.Environment.IsDevelopment()) {    app.UseHsts();}app.UseHttpsRedirection();app.UseStaticFiles();app.UseAuthentication();app.UseAuthorization();app.UseAntiforgery();app.MapGet("/", context => {    context.Response.Redirect("/Home");    return Task.CompletedTask;});app.MapRazorComponents<App>().AddInteractiveServerRenderMode();app.Run();

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>