dotnet / dotnet/aspnetcore

MarkupString should be respected in .cshtml files

Open
#61,239 4 comments 0 reactions 0 assignees View on GitHub
area-ui-rendering
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

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

I have solution with a mix of .cshtml and .razor files (moving from MVC to mixed MVC/Razor components). I have a paradigm where my view models have HtmlString/IHtmlContent fields that could be correctly displayed in .cshtml files just be directly referencing.

HtmlString/IHtmlContent doesn't supported in Razor component, so I have to use MarkupString there.
MarkupString is more lightweight marker concept, and doesn't require framework reference to whole ASP.NET server — I like it.

However, .cshtml renderer doesn't support MarkupString, so I have to manually add Html.Raw here. I don't like it.

### Describe the solution you'd like

1. MarkupString supported in .cshtml files and doesn't re-encoded.
2. Ideally, MarkupString moved even higher in dependecies stack into some MS.Ext. assembly, totally untied from ASP.NET and will become universally recognized "html marker" class.

### Additional context

_No response_

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.