为什么 Orchard 会自动将字符串编码到视图中?

发布于 2024-12-26 17:46:52 字数 726 浏览 1 评论 0原文

在我的驱动程序中,我将动态对象传递给视图,但它会自动编码所有字符串,这会破坏我在视图中构造的链接。

这就是我想要做的:

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&"));
    }
}

当我将以下内容添加到视图中时:

@Model.Test

它呈现如下:

xxxx&amp;

有没有办法阻止这种情况发生?我试图让它准确地渲染“xxxx&”。

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&".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空‖城人不在 2025-01-02 17:46:52

我认为这与果园根本没有关系。
在 Razor 中,一切都是 html 编码的。
你尝试过吗:

@Html.Raw(Model.Test)

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)

?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文