Skip to content

Add RenderFragment-like functionality to pure partials and view components in pure Razor SST #40299

Closed
@MichalSznajder

Description

@MichalSznajder

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.

Currently it is hard to easily pass HTML content into partial or custom component in Razor Pages or MVC scenarios. If you want to create a server side rendered component for box with header only way is to write custom tag helper.

Razor Components (available with Component Tag Helper with static rendering are not a solution since they don't support HtmlHelper and Tag Helpes (so no linking via asp-page or no antiforgery protection in forms).

Describe the solution you'd like

Solution proposed in #4901 would be a good start. There is even example implementation in https://github.com/rdlaitila/AspNetCore.Mvc.ViewComponentSlots.

Additional context

Idea for this comes from Ruby on Rails where you can easily create HTML based components by using partial. See 3.4.2 Using Partials to Simplify Views section from Rails manual.

See also https://andrewlock.net/dont-replace-your-view-components-with-razor-components/ for some problems when tryign to convert from View Component into Razor Component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-mvc-razor-viewsFeatures related to the Razor view engine for Razor pages and MVC views

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions