Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 带Blazor的ASP.NET Core 3.1 MVC-缺少程序集_C#_Asp.net Mvc_Asp.net Core_Blazor_Blazor Server Side - Fatal编程技术网

C# 带Blazor的ASP.NET Core 3.1 MVC-缺少程序集

C# 带Blazor的ASP.NET Core 3.1 MVC-缺少程序集,c#,asp.net-mvc,asp.net-core,blazor,blazor-server-side,C#,Asp.net Mvc,Asp.net Core,Blazor,Blazor Server Side,我正试图遵循以下有关Visual Studio 2019 v16.4.3(非预览)的教程。我首先创建了一个新的Core 3.1 MVC Web应用程序进行测试,然后将其应用到我的其他应用程序中。但是在我需要在Index.cshtml中编写标记帮助程序的部分,我一直得到以下信息: The type or namespace name 'HelloWorld' could not be found (are you missing a using directive or an assembly r

我正试图遵循以下有关Visual Studio 2019 v16.4.3(非预览)的教程。我首先创建了一个新的Core 3.1 MVC Web应用程序进行测试,然后将其应用到我的其他应用程序中。但是在我需要在
Index.cshtml
中编写
标记帮助程序的部分,我一直得到以下信息:

The type or namespace name 'HelloWorld' could not be found (are you missing a using directive or an assembly reference?)    
这是我的
Index.cshtml

@page
@model IndexModel
@{
    ViewBag.Title = "Home Page";
}

<script src="~/_framework/blazor.server.js"></script>
<component type="typeof(HelloWorld)" render-mode="ServerPrerendered" />
我将
HelloWorld.razor
放在解决方案根目录下的
Pages
文件夹中。此外,如果需要,以下是已更改的
Startup.cs
方法:

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllersWithViews();
    services.AddRazorPages();
    services.AddServerSideBlazor();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    ...

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllerRoute(
            name: "default",
            pattern: "{controller=Home}/{action=Index}/{id?}");

        endpoints.MapRazorPages();
        endpoints.MapBlazorHub();
    });
}

我错过了什么?谢谢

显然,我在原始帖子中链接的教程缺少了一些东西。而不是:

typeof(HelloWorld)
应该是这样的:

typeof(<namespace name>.<the folder the .razor file is in>.<the .razor file name>)
typeof(TestMVCBlazor.Pages.HelloWorld)
typeof(TestMVCBlazor.Pages.HelloWorld)