Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要从mvc呈现html,只显示htmls标记而不是文本_Html_Asp.net Mvc 4_Render_Razorpdf - Fatal编程技术网

需要从mvc呈现html,只显示htmls标记而不是文本

需要从mvc呈现html,只显示htmls标记而不是文本,html,asp.net-mvc-4,render,razorpdf,Html,Asp.net Mvc 4,Render,Razorpdf,我正在使用razorpdf在我的MVC4应用程序中生成pdf报告。每次我生成pdf时,description字段都会显示一组不应该显示的html标记和字段,我只希望显示description字段中的纯文本。有人对如何做到这一点有什么建议吗?还有人对如何将图像添加到pdf页面有什么建议吗 这是生成pdf的我的视图: @model List<ArdentMC.DHS.COP.Mobile.MVC.Models.Reports> @{ Layout = ""; } <!DOCTYPE

我正在使用razorpdf在我的MVC4应用程序中生成pdf报告。每次我生成pdf时,description字段都会显示一组不应该显示的html标记和字段,我只希望显示description字段中的纯文本。有人对如何做到这一点有什么建议吗?还有人对如何将图像添加到pdf页面有什么建议吗

这是生成pdf的我的视图:

@model List<ArdentMC.DHS.COP.Mobile.MVC.Models.Reports>
@{
Layout = "";
}
<!DOCTYPE html>
<html>
<head>
    <div style="color=red; align:center;">UNCLASSIFIED/FOR OFFICAL USE ONLY</div>

</head>
<body>

<table style="width:300px;">
   @foreach (var item in Model)
{
<tr>
<td>@item.Phase</td>
<td>@item.NocNumber</td>
<td>@item.Title</td>
<td>@item.Location</td>
</tr>
    <tr<
    <td></td>
    <td></td> 
    <td>@item.ReportDateText</td>
    <td>@item.Description</td>
    </tr>     
}
</table>                             
    <br /><br /><br /><br /><br />
    <br /><br /><br /><br /><br />
     <div style="color:black; align:center;">US Department of Homeland Security</div>
        <br />
        <div style="color:red; align:center;">UNCLASSIFIED/FOR OFFICAL USE ONLY</div>

</body>
</html>
@型号列表
@{
布局=”;
}
非机密/仅供官方使用
@foreach(模型中的var项目)
{
@项目.阶段
@项目编号
@项目.标题
@项目.地点
我可以补充说
@foreach(模型中的var项目){
@Html.Raw(item.Description)

}在我的视图中,它为描述字段提供了正确的代码,这样就没有可查看的标记,只有文本。

视图中的body标记外有HTML,这会导致问题吗?在循环中创建的行中也有列不匹配的情况,第一行有4列,第二行只有2列。Either将'colspan=2'添加到第二行或添加更多行。这两种方法都没有效果…我尝试了@html.raw,但这似乎也不起作用,有人告诉我需要以某种方式呈现html,但我没有足够的经验使其发挥作用…在这里,答案必须有一个解释,我不会将其标记为删除ATM,但我敦促你你需要解释你的答案。
public ActionResult NotFound() {
    Response.ContentType = "text/html";
    return View();
}
public ActionResult NotFound() {
    Response.ContentType = "text/html";
    return View();
}