运行已发布的应用程序后,无法找到由路由值指定的回退端点:{页面:/_ Host,区域:} [英] Running published app gives Cannot find the fallback endpoint specified by route values: { page: /_Host, area: }

查看:229
本文介绍了运行已发布的应用程序后,无法找到由路由值指定的回退端点:{页面:/_ Host,区域:}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 Blazor Server 网络应用程序,并通过右键单击该项目从 Visual Studio 发布了它-发布.我正在发布到本地文件夹,除其他外,输出包括 MyProject.exe 运行正常:

I created a Blazor Server webapp and published it from Visual Studio using right click on the project - publish. I am publishing to a local folder, amongst others the output includes MyProject.exe Running that works fine:

info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production

但是我无法在 http://localhost:5000 https://localhost:5001 上访问我的Web应用.Chrome只是给了我 HTTP错误500 .在启动 MyProject.exe 的控制台中,我可以找到此错误:

However I can not access my webapp on http://localhost:5000 or https://localhost:5001.Chrome just gives me HTTP ERROR 500. In the console where I started MyProject.exe I can find this error:

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.InvalidOperationException: Cannot find the fallback endpoint specified by route values: { page: /_Host, area:  }.
         at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DynamicPageEndpointMatcherPolicy.ApplyAsync(HttpContext httpContext, CandidateSet candidates)
         at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet)
         at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|8_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[3]

有人可以帮我吗?当我从Visual Studio运行Web应用程序时,一切正常!我的 Index.razor 页面位于默认的/Pages 文件夹中.

Can anyone help me with this? When I run my webapp from Visual Studio, everything works fine! My Index.razor page is in the default /Pages folder.

请注意,我已经检查了具有此错误的其他帖子:找不到由路由指定的后备端点值:{页面:/_Host,区域:} 虽然没有任何改变.

Please note that I already checked other posts with this error: Cannot find the fallback endpoint specified by route values: { page: /_Host, area: } It didn't change anything though.

推荐答案

我发现发布项目时未包含名为{project名称空间} .Views.dll的文件.我能够从bin \ Release \ netcoreapp3.1 \文件夹中抓取它.将文件复制到网站文件夹后,我不再遇到该错误,并且网站正常运行.

I found that a file named {project namespace}.Views.dll was not being included when publishing the project. I was able to grab it from the bin\Release\netcoreapp3.1\ folder. Once I copied that file to the website folder, I no longer got that error and the website worked properly.

此外,我不知道这是否是一个相关问题,但是发布也没有在wwwroot文件夹中包含文件夹.我不得不将这些复制到自己身上.

Also, I don't know if this is a related issue, but the publish also did not include folders in the wwwroot folder. I had to copy those over myself.

这篇关于运行已发布的应用程序后,无法找到由路由值指定的回退端点:{页面:/_ Host,区域:}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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