找不到路由值指定的后备端点:{页面:/_ Host,区域:} [英] Cannot find the fallback endpoint specified by route values: { page: /_Host, area: }
本文介绍了找不到路由值指定的后备端点:{页面:/_ 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");
});
如何解决此错误?
推荐答案
- 确保在
_Host的
文件.< head/>
标记内包含< base href =〜/"/>
声明.cshtml - 确保在
ConfigureServices(IServiceCollection服务)
方法内指定services.Configure< RazorPagesOptions>(options => options.RootDirectory ="/Pages");
Startup.cs
文件(如果您自定义Pages
位置). - 尝试删除
endpoints.MapDefaultControllerRoute();
并检查其是否干扰您的路由. - 尝试将
_Host.cshtml
文件放置在页面的RootDirectory
中. - 验证您在
_Host.cshtml
文件顶部指定了@page"/"
和@namespace< MatchingYourRootPagesDir>
.
- 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.
这篇关于找不到路由值指定的后备端点:{页面:/_ Host,区域:}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文