Skip to content

Add helper methods for constructing a RazorComponentResult #47094

@SteveSandersonMS

Description

@SteveSandersonMS

This is to follow up on #47023 (comment) and #47023 (comment)

Currently, you have to construct a RazorComponentResult manually, e.g.:

// Minimal
endpoints.Map("/mypage", () => new RazorComponentResult<MyPageComponent>());

// MVC
public IResult MyPage()
    => new RazorComponentResult<MyPageComponent>(new { Greeting = "Hmm" });

For consistency with other built-in result types, we probably also want helpers so you can do things like:

// Minimal
endpoints.Map("/mypage", () => Results.RazorComponent<MyPageComponent>());

// MVC
public IResult MyPage()
    => RazorComponent<MyPageComponent>(new { Greeting = "Hmm" });

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions