-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I'm creating a simple component that inherits from a ComponentBase class, and my understanding is that I can use the Route attribute in the base class instead of the @page directive, unfortunately when I do that, I don't get an error but the page is just blank
BLAZOR COMPONENT:
@inherits EmployeeListBase
<h3>Employee List</h3>
COMPONENT CLASS
using EmployeeManagement.Models;
using Microsoft.AspNetCore.Components;
namespace EmployeeManagement.Web.Pages
{
[Route("/")]
public class EmployeeListBase : ComponentBase
{
public IEnumerable<Employee> Employees { get; set; } = new List<Employee>();
}
}
So basically, this should act as the root page of the razor web, instead, it just displays a blank page, no h3 text, nothing, just blank as follow
Expected Behavior
If I don't use the Route attribute on the base class and use the @page directive in the component, then it work as expected:
According to the docs at https://docs.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-6.0 in the Routing section it states the following:
When a Razor file with an @page directive is compiled, the generated class is given a RouteAttribute specifying the route template.
Thank you so much for all your help! If I'm doing something wrong, PLEASE let me know, thank you.:-)
Steps To Reproduce
No response
Exceptions (if any)
No exceptions, just a blank page is returned.
.NET Version
6
Anything else?
No response