Skip to content

Blazor, Feature Request: Make @renderMode an attribute, similar to how @page works. #63736

@fArtuCh

Description

@fArtuCh

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I’m creating Razor components from code by inheriting from ComponentBase. This approach allows me to set attributes like [Route("/Address")] easily. However, I cannot do the same for @renderMode.

I’ve converted many of my pages to be built via code using:

protected override void BuildRenderTree(RenderTreeBuilder __builder)

While this approach works well and gives me benefits such as better hot reload and better project structure, I’ve lost the ability to control render modes.

Using .cs files that inherit from ComponentBase is convenient, but I need a way to specify the RenderMode for these programmatically-built components.

Describe the solution you'd like

I would like to be able to add Attribute [RenderMode(RederModeOption)]. This attribute will influence building and linking options for blazor project and could replace @rendermode directive in the .razor file.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions