【发布时间】:2023-03-26 11:22:01
【问题描述】:
多年来,对此有很多答案,在有人对我大喊大叫之前,我已经尝试了所有方法,但无法正常工作。我正在使用 MVC 5、Razor 3、Visual Studio 2017。这是一个简化的测试:
在我的 App_Code 文件夹中,我有一个 SSLhelpers.cshtml 文件,其中包含:
@helper Macro(string Htext, string Ptext)
{
<h2>@Htext</h2>
<p>@Ptext</p>
}
在我看来,我有:
@SSLhelpers.Macro("This is my header", "This is my paragraph text. We should
be <strong>bold</strong> here but we're not.")
生成的html是:
<h2>This is my header</h2>
<p>This is my paragraph text. We should be <strong>bold</strong>
here but we're not.</p>
如何避免编码?
谢谢。
【问题讨论】:
标签: c# asp.net asp.net-mvc razor razorengine