Why is Orchard auto-encoding strings to the view?
-
27-10-2019 - |
Question
In my driver, I am passing the dynamic object to the view, but it is automatically encoding all my strings which is mangling the links I am constructing in the view.
Here is what I am trying to do:
public class SomeWidgetDriver : ContentPartDriver<SomeWidgetPart>
{
// GET
protected override DriverResult Display(SomeWidgetPart part, string displayType, dynamic shapeHelper)
{
return ContentShape("Parts_SomeWidget",
() => shapeHelper.Parts_SomeWidget(
AppUrl: part.AppUrl,
AppVersion: part.AppVersion,
RenderTo: part.RenderTo,
Test: "xxxx&"));
}
}
When I add the below to the view:
@Model.Test
It renders like this:
xxxx&
Is there a way to stop this from happening? I am trying to get it to exactly render "xxxx&".
Solution
I don't think this has to do with Orchard at all. In Razor everything is html encoded. Did you try:
@Html.Raw(Model.Test)
?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow