简体   繁体   English

使用 html.raw 在 razor 视图内渲染外部 Html 视图扭曲了页面 ZFC35FDC70D5FC69D5A26

[英]Rendering external Html inside razor view using html.raw is distorting page html

I have an external Html - which is actually an emails body, it has html tag and body, it is complete html in itself.我有一个外部 Html - 它实际上是一个电子邮件正文,它有 html 标签和正文,它本身就是完整的 html。 I am rendering that inside Bootstrap modal我在 Bootstrap 模式中渲染它

 <div class="modal-body">
            @Html.Raw(Model.EmailBody)
            @*<iframe srcdoc="@Html.Raw(Model.EmailBody)">
            </iframe>*@
</div>

But my page has other divs which is going somewhere inside the Email Body and my divs going inside Email's html.但是我的页面还有其他 div 位于 Email Body 的某个地方,而我的 div 位于 Email 的 html 中。

So I tried to render external html inside an iframe and in that case My view is not distorted but somehow Email content is not coming inside iframe.所以我尝试在 iframe 内渲染外部 html ,在这种情况下,我的视图没有失真,但不知何故 Email 内容没有进入 ZA2598E4F26AFAD2DF8661FDC477 When I look in dom its showing like this当我看 dom 时,它的显示是这样的

<iframe srcdoc="<!DOCTYPE html PUBLIC " -="" w3c="" dtd="" xhtml="" 1.0="" transitional="" en"="" "http:="" www.w3.org="" tr="" xhtml1="" xhtml1-transitional.dtd"="">  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">       <!-- Email Header -->  <head>  <meta http-equiv="Content-Type" content="html; charset=UTF-8"></meta>   <!-- Included header file, can be cloned and/or replaced. -->    <!--[if gte mso 15]>  <xml>   <o:OfficeDocumentSettings>   <o:AllowPNG/>   <o:PixelsPerInch>96</o:PixelsPerInch>   </o:OfficeDocumentSettings>  </xml>  <![endif]-->  <meta charset="UTF-8" />  <!--[if !mso]><!-->    <meta http-equiv="X-UA-Compatible" content="IE=edge" />   <!--<![endif]-->  <meta name="viewport" content="width=device-width, initial-scale=1" />  <title></title>      <!--[if mso]>  <style type="text/css">  body, table, td {font-family: Arial, Helvetica, sans-serif !important;}  h1 {font-family: Arial, Helvetica, sans-serif !important;}  h2 {font-family: Arial, Helvetica, sans-serif !important;}  h3 {font-family: Arial, Helvetica, sans-serif !important;}  h4 {font-family: Arial, Helvetica, sans-serif !important;}  h5 {font-family: Arial, Helvetica, sans-serif !important;}  h6 {font-family: Arial, Helvetica, sans-serif !important;}  h7 {font-family: Arial, Helvetica, sans-serif !important;}  p {font-family: Arial, Helvetica, sans-serif !important;}  </style>  <![endif]-->    <!--[if gt mso 15]>  <style type="text/css" media="all">  /* Outlook 2016 Height Fix */  table, tr, td {border-collapse: collapse;}  tr {border-collapse: collapse; }  body {background-color:#ffffff;}  </style>  <![endif]-->    <!-- Title - Optional content - The title tag shows in email notifications on mobile devices -->  <title>    </title>  <style type="text/css">  p.solid {border-style: solid;border-width: 1px;padding: 5px}  button-style {background: #222222; border: 15px solid #222222; padding: 0 10px;color: #ffffff; font-family:Ember, Arial, sans-serif; font-size: 13px; line-height: 1.1; text-align: center; text-decoration: none; display: block; border-radius: 3px; font-weight: bold;}  tablebutton {    border-collapse: separate;  border-spacing: 10px;}  </style>  </head>    <!-- Email Body --> </html>">

    </iframe>

But I am unable to see the html.但我看不到 html。 Is there any other way without or with iframe I can show my external emails有没有其他方法没有或没有 iframe 我可以显示我的外部电子邮件

I have done this using CkEditor.我已经使用 CkEditor 完成了这项工作。 In CkEditor I am showing the html.在 CkEditor 中,我展示了 html。 Its resolving issue, but its not great solution它解决了问题,但不是很好的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM