question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using MapFallbackToPage with a page called Index.cshtml leads to an ambiguious match

See original GitHub issue

Repro

  1. Create a new Server-Side Blazor app.
  2. Rename Pages/_Host.cshtml -> Pages/Index.cshtml.
  3. Navigate to /Index in the app.

This results in an ambiguous match from routing because a page named Index produces two endpoints. This isn’t ideal because it can be a useful pattern to place a page in the app route and then use fallback routing.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

15reactions
iAlexanderMooncommented, Sep 30, 2019

Well… I think I just ran into it this. Been pulling my hair out trying to figure out how I was getting 2 endpoints for a fallback to a razor page to serve a simple spa.

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapRazorPages();    
        endpoints.MapFallbackToPage("/Index");
    });

If / is requested it doesn’t reach the fallback and is served… however… any request expected to be handled by the client hits the fallback and the following error is generated:

Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches: 
/Index
/Index
4reactions
glatzertcommented, Sep 20, 2022

We ran into this as well. We can alleviate the problem by using @page "/" on Index.cshtml. But it’s a lot of head-scratching.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do I get this AmbiguousMatchException?
The ambiguous exception occurs because there are two routes that match the endpoint for /Index .
Read more >
Routing in ASP.NET Core
NET Core routing is responsible for matching HTTP requests and dispatching to ... as the best match, an ambiguous match exception is thrown....
Read more >
ASP.NET Core Blazor routing and navigation
This article explains how to manage Blazor app request routing and how to use the NavLink component to create navigation links.
Read more >
Routing in Razor Pages
cshtml to the root pages folder and attempt to browse to it, an exception will be raised: AmbiguousActionException: Multiple actions matched.
Read more >
Pro ASP.NET Core 6
Using MVC, Blazor, and Razor Pages ... every occurrence of a trademarked name, logo, or image we use the names, logos, ... Using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found