找不到路由值指定的后备端点:{页面:/_ Host,区域:} [英] Cannot find the fallback endpoint specified by route values: { page: /_Host, area: }

查看:37
本文介绍了找不到路由值指定的后备端点:{页面:/_ Host,区域:}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此项目,并创建了一个完全像它的项目,但是收到

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

找不到路由值指定的后备端点:{页面:/_ Host,区域:}.

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");               
            });

如何解决此错误?

推荐答案

  1. 确保在 _Host的< head/> 标记内包含< base href =〜/"/> 声明.cshtml 文件.
  2. 确保在 ConfigureServices(IServiceCollection服务)方法内指定 services.Configure< RazorPagesOptions>(options => options.RootDirectory ="/Pages"); Startup.cs 文件(如果您自定义 Pages 位置).
  3. 尝试删除 endpoints.MapDefaultControllerRoute(); 并检查其是否干扰您的路由.
  4. 尝试将 _Host.cshtml 文件放置在页面的 RootDirectory 中.
  5. 验证您在 _Host.cshtml 文件顶部指定了 @page"/" @namespace< MatchingYourRootPagesDir> .
  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.

这篇关于找不到路由值指定的后备端点:{页面:/_ Host,区域:}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆