AmbiguousMatchException in net8 Blazor web app

ayman awadallah 30 Reputation points
2024-01-06T18:25:33.9666667+00:00

I am encountering an AmbiguousMatchException error in my client-side Blazor web app. The error message says "The request matched multiple endpoints. Matches: Fallback {*path:nonfile}". I tried to add app.razor containing this lines

<body>
    <div id="app"></div>
</body>

to aoo.razor ; to fix it, but it did not work. I also added builder.RootComponents.Add("#app"); to program.cs but still couldn't solve it. Can anyone help me solve this issue? Here is the page I am trying to call:

   @page "/add-Product"
<div class="container">
    <div class="row">
        <div class="col-md-6">
            <EditForm Model="MyProduct" Enhance OnInvalidSubmit="HandleSaveProduct" >
                <DataAnnotationsValidator/>
                <ValidationSummary></ValidationSummary>
               <div class="card">
                   <div class="card-header">Add Product</div>
                   <div class="card-body">

                   </div>
                   <div class="card-footer">
                         <button type="submit" class="btn btn-primary"><i class="fa-solid fa-floppy-disk"></i>Save</button>
                   </div>
               </div>
            </EditForm>
        </div>
    </div>
</div>
 @code {
    Product MyProduct = new();
    public void HandleSaveProduct()
    {
        
    }
}
.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,103 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,815 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,672 questions
{count} votes

2 answers

Sort by: Most helpful
  1. ayman awadallah 30 Reputation points
    2024-01-07T20:09:38.07+00:00
    the solution is adding app.MapRazorComponents<App>()
        .AddInteractiveServerRenderMode()
        .AddInteractiveWebAssemblyRenderMode()
        .AddAdditionalAssemblies(typeof(AddUpdateProduct).Assembly); to program.cs  in server side while the AddUpdateProduct is the component in clientside
    
    1 person found this answer helpful.
    0 comments No comments

  2. master_lam 0 Reputation points
    2025-04-21T01:11:25.47+00:00

    I have same issue with SignalR + Net core 8. My solution: remove app.MapBlazorHub(); in Program.cs file.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.