dotnet / dotnet/aspnetcore

Add helper methods for constructing a RazorComponentResult

Open
#47,094 9 comments 2 reactions 0 assignees View on GitHub
area-blazor enhancement feature-full-stack-web-ui Pillar: Complete Blazor Web
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

This is to follow up on https://github.com/dotnet/aspnetcore/pull/47023#issuecomment-1458553319 and https://github.com/dotnet/aspnetcore/pull/47023#issuecomment-1458559036

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

```cs
// Minimal
endpoints.Map("/mypage", () => new RazorComponentResult());

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

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

```cs
// Minimal
endpoints.Map("/mypage", () => Results.RazorComponent());

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.