简体   繁体   English

Blazor,在子文件夹中添加了 a.razor 页面,现在应用程序无法启动

[英]Blazor, Added a .razor page in a SubFolder, Now app doesn't start

I have a folder structure /Pages/Home/... with some pages that works, Now I ccreated a subfolder in Home: /Pages/Home/DrawerComponents and added a.razor to it with the full path: /Pages/Home/DrawerComponents/SubFolders.razor.我有一个文件夹结构 /Pages/Home/... 有一些可用的页面,现在我在 Home 中创建了一个子文件夹:/Pages/Home/DrawerComponents 并添加了 a.razor 到它的完整路径:/Pages/Home/抽屉组件/子文件夹.razor。

But the new.razor page causes app not to start, I use VS 2019 16.11.11 and Windows Forms with Blazor .NET 6.0.但是new.razor页面导致app无法启动,我用VS 2019 16.11.11和Windows Forms和Blazor .NET 6.0。

The SubFolders.razor content is: SubFolders.razor 的内容是:

@layout MainLayout
@page "/subfolder/{DrawerID:int}/{FolderID:int}/{FolderName:string}"

<RadzenLink Path="@($"/drawer/{DrawerID}")" Text="Folders"></RadzenLink>

<h3>@FolderName</h3>


@code {

    [Parameter]
    public int DrawerID { get; set; }

    [Parameter]
    public int FolderID { get; set; }

    [Parameter]
    public string FolderName { get; set; }
}

and all of the app services are Imported to it.并且所有应用程序服务都已导入其中。

Application does not start with error: NullReferenceException.应用程序未启动并出现错误:NullReferenceException。

when I exclude this.razor file App starts normaly.当我排除 this.razor 文件时,应用程序正常启动。 What is this and how to fix this?这是什么以及如何解决这个问题?

EDIT: This is not a start page or a page that is referenced any where, When app starts.编辑:这不是起始页,也不是应用程序启动时在任何地方引用的页面。 So This exception may be caused by project structure not the famous NullReferenceException.所以这个异常可能是由项目结构引起的,而不是著名的 NullReferenceException。

I changed the page directive to:我将页面指令更改为:

@page "/subfolder/{DrawerID:int}/{FolderID:int}/{FolderName}" @page "/subfolder/{DrawerID:int}/{FolderID:int}/{FolderName}"

and it runs good, I didn't enabled Nullable Reference Types so {FolderName:string} was Nullable and caused error.它运行良好,我没有启用 Nullable Reference Types 所以 {FolderName:string} 是 Nullable 并导致错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Blazor 应用程序的 Razor 页面中添加多个模型? - How to have multiple models added in Razor page of Blazor app? 如何在 Razor Dotnet core projet 的子文件夹中运行 Blazor app projet? - How to run Blazor app projet in subfolder of Razor Dotnet core projet? css 与 Blazor 隔离 - css 不会改变 my.razor - css isolation with Blazor - css doesn't change my .razor 如何在 Blazor 服务器应用程序中导航到文件夹的默认页面 (.razor)? - How to navigate to a folder's default page (.razor) in Blazor Server app? Blazor 应用程序 Razor 页面的 InputText 中的绑定类型双精度值 - Binding Type double values in InputText of Blazor app Razor page 当 ASPNETCORE_ENVIRONMENT 更改为“开发”以外的任何内容时 - Blazor 应用程序在调试 VS 时在 VS2F2ED4F8EBC2CBB4C21A29DC40AB61DZ 库中看不到来自 razor class 库的资源 - When ASPNETCORE_ENVIRONMENT changed to anything but "Development" - Blazor app doesn't see resources from razor class libraries when debugged in VS 如何从 Blazor 服务器端应用程序中的 razor 页面导航到 blazor 组件? - How to navigate to a blazor component from a razor page in a Blazor server-side app? 标识 razor 页面中的 Blazor 组件 - Blazor component in identity razor page Blazor 允许匿名 Razor 页面 - Blazor Allow Anonymous For Razor Page razor 页面 (blazor) 正在对字符进行编码 - razor page (blazor) is encoding the characters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM