HtmlHelpers in Razor Class Library #54860
Replies: 2 comments
-
I also notice HtmlHelpers is available in an RCL if I choose the option to support older style cshtml Views. The RCL for razor views is missing a Frameworks reference to Microsoft.AspNetCore.App. Is there a reason this is omitted? |
Beta Was this translation helpful? Give feedback.
-
So what I think I've come to realize is these two types of RCL libraries are very different. I mistakenly thought one was just generating *.razor files as a different way to organize code, but otherwise similar capabilities to *.cshtml pages. With "Support Pages and Views" unchecked, you don't have access to alot of legacy capabilities, and as far as I can tell this is intentional because of how the rendering engine was changed. So while you can have two RCL libraries, their capabilities are fairly different and the APIs for doing advanced rendering are very different. I feel like the checkbox for the template for "Support Pages and Views" doesn't fully convey how different these templates are. I feel like there should be two templates with different names. Also as far as I can tell using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm new to Razor Class Libraries and was trying to locate Html.Raw that I'm familiar with from MVC(I understand how to use it safely). It seems like there's alot of different alternatives like HtmlString, but each avenue leads to either something that doesn't seem to work in a RCL or the recommended Microsoft nuget package is marked deprecated.
How do I access HtmlHelpers from a RCL?
It looks like HtmlString is contained within the package Microsoft.AspNetCore.App.Ref, but trying to add a ref to that via nuget to an RCL results in:
Beta Was this translation helpful? Give feedback.
All reactions