I am relatively new to blazor. I have created a razor page with login functionality, that attaches a cookie with a redirect, when login is ok.
My test flow:When I run my app, i'll need to show 'index.cshtml'Here I 'log in', which make a form post to the CS code, that: return Redirect("/secret/home");SecretHome.razor is a blazor page that shows users name, so i know I'm logged in. I't located on: @page "/secret/home"This page also have a: navManager.NavigateTo("/secret/todo/NavManager");Last page is: @page "/secret/todo/{id}"
The error:Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]An unhandled exception has occurred while executing the request.Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches:
Blazor initializers Fallback {*path:nonfile} at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(Span`1 candidateState) at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ProcessFinalCandidates(HttpContext httpContext, Span`1 candidateState) at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.Select(HttpContext httpContext, Span`1 candidateState) at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.MatchAsync(HttpContext httpContext) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)My program.cs
var builder = WebApplication.CreateBuilder(args);builder.Services.AddRazorPages();builder.Services.AddRazorComponents().AddInteractiveServerComponents();builder.Services.AddHttpContextAccessor();builder.Services.AddHttpContextAccessor();builder.Services.AddTransient<FakeAuthRepo>();builder.Services.AddSingleton<UserService>();builder.Services.AddSingleton<IAuthRepo, FakeAuthRepo>();var app = builder.Build();app.UseStaticFiles();app.UseRouting();app.UseHttpsRedirection();app.UseAntiforgery();app.MapControllers();app.MapBlazorHub();app.MapRazorPages();app.MapRazorComponents<App>().AddInteractiveServerRenderMode();app.MapFallbackToFile("index.html");app.Run();As I said, it seems like everything works fine, but I get this error and I suspect I at somehow would come over an issue due to that error, so I really would like it to go away.
I hope someone can help. Thanks.