我有一个带有 CSHTML 视图的 MVC 应用程序
有 2 个问题,其文本为“这是要搜索的网站 Google”。 文本存储在数据库中并显示在 cshtml 页面上,该页面将呈现为 HTML 和 PDF。
问题是 html 上的链接,PDF 呈现如下
"This is the website <a href="https://google.com/">Google</a> to search."
全文
但是我需要将其呈现为“这是要搜索的网站 Google”。 (其中 Google 作为超链接)
我呈现的问题如下 - 对于其他问题,它工作正常,但需要正确呈现超链接。
@foreach (var question in @Model.Questions)
{
<p>
<div>@question.Description</div>
<div style="padding-left:10px;">[email protected]</div>
</p>
}
您能否提供有关在 HTML 和 PDF 上正确呈现超链接的帮助和建议。
我通过在 @Html.Raw() 中添加模型值解决了这个问题
Eg : <div>@Html.Raw(@question.Question1)</div>
希望这对某人有帮助:)