问题
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.cshtmlfile. - Make sure to specify
services.Configure<RazorPagesOptions>(options => options.RootDirectory = "/Pages");insideConfigureServices(IServiceCollection services)method inStartup.csfile if you customised yourPageslocation. - Try to remove
endpoints.MapDefaultControllerRoute();and check if it interferes with your routing. - Try to place your
_Host.cshtmlfile inside theRootDirectoryof your pages. - Verify that you have
@page "/"and@namespace <MatchingYourRootPagesDir>specified on the top of_Host.cshtmlfile.
来源:https://stackoverflow.com/questions/58874883/cannot-find-the-fallback-endpoint-specified-by-route-values-page-host-are