RazorEngine:不能使用 Html.Raw [英] RazorEngine: cannot use Html.Raw

查看:24
本文介绍了RazorEngine:不能使用 Html.Raw的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 asp.net 之外使用 RazorEngine 我在尝试使用 @Html.Raw("html string here") 编写原始 html 时遇到此错误:

using RazorEngine outside asp.net I'm experiencing this error when I try to write raw html by using @Html.Raw("html string here"):

无法编译模板.当前上下文中不存在名称Html"

Unable to compile template. The name 'Html' does not exist in the current context

你能帮我吗?

谢谢!

推荐答案

已在此处找到解决方案:https://github.com/Antaris/RazorEngine/issues/34

The solution has been found here: https://github.com/Antaris/RazorEngine/issues/34

使用 @(new RawString("html string here"))@Raw("html string here") 代替 @Html 就足够了.Raw("这里的html字符串").

It's enough to use @(new RawString("html string here")) or @Raw("html string here") instead of @Html.Raw("html string here").

我希望这会有所帮助!再见

I hope this helps! Bye

这篇关于RazorEngine:不能使用 Html.Raw的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆