【问题标题】:HTML Helper not recognizing "@Html.InlineImage"HTML Helper 无法识别“@Html.InlineImage”
【发布时间】:2013-10-10 15:39:49
【问题描述】:

我正在尝试在 MVCMailer 中嵌入电子邮件图像。 Github MvcMailer Step by Step Guide 确实提供了如下所示的解决方案:

分步指南:

//Place this in the View:
@Html.InlineImage("logo", "Company Logo")

//Place this in the mailer:
var resources = new Dictionary<string, string>();
resources["logo"] = logoPath;
PopulateBody(mailMessage, "WelcomeMessage", resources);

我的问题是,视图无法识别@Html.InlineImage。它识别其他 html 助手,而不是“InlineImage”。事实上,当我输入 @Html 时,它永远不会出现在 intellisense 中。

我认为这在 MVC 4 中不受支持。谁能指出我正确的方向并告诉我需要做什么才能使其正常工作?

【问题讨论】:

  • 仅供参考,这是我收到的错误消息:编译器错误消息:CS1061:“System.Web.Mvc.HtmlHelper”不包含“InlineImage”的定义并且没有扩展名可以找到接受“System.Web.Mvc.HtmlHelper”类型的第一个参数的方法“InlineImage”(您是否缺少 using 指令或程序集引用?)
  • 确保您拥有该视图范围的真实配置。检查本地 web.config 文件内容。我们假设您已将相关的程序集引用包含到您的项目中。

标签: asp.net-mvc-4 email razor html-helper mvcmailer


【解决方案1】:

我知道为时已晚,但我通过添加“@using Mvc.Mailer;”解决了它在电子邮件视图的顶部。

【讨论】:

    【解决方案2】:

    我没有弄清楚@Html.InlineImage 问题,但我确实找到了解决方法。只需使用: &lt;img style="width: 243px; height: 91px" src="cid:logo" alt="Logo"/&gt; 在我看来解决了这个问题。感谢大家寻求帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-11
      • 2013-05-28
      相关资源
      最近更新 更多