Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find the fallback endpoint specified by route values: { page: /_Host, area: }

Tags:

blazor

I use This Project and created a project exactly like it, But receive

Cannot find the fallback endpoint specified by route values: { page: /_Host, area: }.

Error when I start the project, In the startup configure method I have:

 app.UseEndpoints(endpoints =>
            {
                endpoints.MapBlazorHub();
                endpoints.MapDefaultControllerRoute();
                endpoints.MapFallbackToPage("/_Host");               
            });

How to resolve this error?

like image 995
mz1378 Avatar asked Dec 02 '22 09:12

mz1378


2 Answers

  1. Make sure that you have <base href="~/" /> declaration inside the <head /> tag in your _Host.cshtml file.
  2. Make sure to specify services.Configure<RazorPagesOptions>(options => options.RootDirectory = "/Pages"); inside ConfigureServices(IServiceCollection services) method in Startup.cs file if you customised your Pages location.
  3. Try to remove endpoints.MapDefaultControllerRoute(); and check if it interferes with your routing.
  4. Try to place your _Host.cshtml file inside the RootDirectory of your pages.
  5. Verify that you have @page "/" and @namespace <MatchingYourRootPagesDir> specified on the top of _Host.cshtml file.
like image 139
rvnlord Avatar answered Dec 27 '22 05:12

rvnlord


If you updating project SDK to .NET 6, you can add following property into your .csproj file

<PropertyGroup>
  <UseRazorSourceGenerator>false</UseRazorSourceGenerator>
</PropertyGroup>

Source: https://github.com/dotnet/aspnetcore/issues/36535#issuecomment-919861308

like image 32
azhe403 Avatar answered Dec 27 '22 07:12

azhe403