Running published app gives Cannot find the fallback endpoint specified by route values: { page: /_Host, area: }

Viewed 992

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

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]

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.

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.

1 Answers

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.

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.

Related