在MVC中找不到HtmlHelper类

时间:2017-05-04 08:23:36

标签: c# asp.net-mvc html-helper

您好我想在MVC中使用HtmlHelper。但它没有得到承认。所以我尝试使用System.Web.WebPages.Html 添加。但是在我的代码中添加此内容后,无法识别 AnonymousObjectToHtmlAttributes 。它是被贬低还是其他什么?

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.WebPages.Html;
namespace TestFrame
{
    internal class IframeBuilder
    {
        internal static HtmlString Iframe(object htmlAttributes)
        {
            IDictionary<string, object> parsedHtmlAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);

            TestFrame.IframeId = GetId(parsedHtmlAttributes);

            string parsedIframe = CreateIframeTag(parsedHtmlAttributes);
            parsedIframe += ReceiveMessageScript();
            parsedIframe += SetIframeIdScript();

            return new HtmlString(parsedIframe);
        }
    }

1 个答案:

答案 0 :(得分:1)

HtmlHelperSystem.Web.Mvc的一部分。 如果您错过了添加System.Web.Mvc.dll或者dll丢失或者dll存在问题,可能会导致此问题。

  

解决问题的步骤:

     
      
  1. 确保在参考
  2. 中添加了dll   
  3. 确保dll引用正确
  4.   
  5. 确保dll文件存在
  6.   
  7. 删除dll并重新添加(正如Filburt在评论中所建议的那样)
  8.