'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.

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.

The SubFolders.razor content is:

@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.

when I exclude this .razor file App starts normaly. 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.



Solution 1:[1]

I changed the page directive to:

@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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mz1378