问题
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?
回答1:
- Make sure that you have
<base href="~/" />
declaration inside the<head />
tag in your_Host.cshtml
file. - Make sure to specify
services.Configure<RazorPagesOptions>(options => options.RootDirectory = "/Pages");
insideConfigureServices(IServiceCollection services)
method inStartup.cs
file if you customised yourPages
location. - Try to remove
endpoints.MapDefaultControllerRoute();
and check if it interferes with your routing. - Try to place your
_Host.cshtml
file inside theRootDirectory
of your pages. - Verify that you have
@page "/"
and@namespace <MatchingYourRootPagesDir>
specified on the top of_Host.cshtml
file.
来源:https://stackoverflow.com/questions/58874883/cannot-find-the-fallback-endpoint-specified-by-route-values-page-host-are