将Blazor服务器站点5升级到6时出现问题 [英] Trouble upgrading Blazor Server site 5 to 6
本文介绍了将Blazor服务器站点5升级到6时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我做到了:
- 新建6.0项目
- 将所有组件和代码等复制到新项目
- 将我过去在
Startup.cs
中的服务添加到Program.cs
- 将我的全局使用移动到新文件
Globals.cs
代码编译并开始运行,但在分解之前从不显示任何内容。
问题
在_Host.cshtml
中,最后一行现在引发空引用错误:
@page "/"
@namespace BEC.web.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = "_Layout";
}
<component type="typeof(App)" render-mode="ServerPrerendered" />
我知道这个问题很难回答,但我想知道有没有人能稍微指出我哪里出错了。
推荐答案
定义分解(&P)。
我猜测它位于&qot;/";路径中加载的一个组件中。正如您所说,当您的应用程序爆炸时,Net6中引入的错误报告中存在一些问题。例如-https://github.com/dotnet/aspnetcore/issues/38380。
试着创建一个最小的应用程序,看看会发生什么--没有路由器,只有一些普通的html输出。看看会发生什么。然后添加路由器,但要使用固定内容查看路由器是否正常。我在下面添加了一些代码,以向您展示要尝试的内容。@*<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
*@
@* Step 1*@
Hello World
@* Step 2*@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
Found
</Found>
<NotFound>
Not Found
</NotFound>
</Router>
@* Step 3*@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<StackOverflow.Server.Pages.Index />
</Found>
<NotFound>
Not Found
</NotFound>
</Router>
这篇关于将Blazor服务器站点5升级到6时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文