html-helper - MVC 4 中的自定义 html 助手

标签 html-helper asp.net-mvc-4

我创建了助手类

namespace SEM.API.Helpers
{
    public static class Navigation
    {
        public static string BuildSomething(this HtmlHelper helper)
        {
            return "empty";
        }
    }
}

并将命名空间添加到 webconfig <add namespace="SEM.API.Helpers" />但我仍然收到错误消息:

CS1061: "System.Web.Mvc.HtmlHelper"



重装了很多次都没解决

最佳答案

and added namespace to webconfig <add namespace="SEM.API.Helpers" />



确保您在 ~/Views/web.config 中执行此操作而不是在 ~/web.config .

另一件要尝试的事情是添加 @using对您的看法的指示:
@using SEM.API.Helpers
@Html.BuildSomething()

关于html-helper - MVC 4 中的自定义 html 助手,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10998827/

相关文章:

asp.net-mvc-2 - ASP.NET MVC 2 动态生成模型中的数据注释

asp.net-mvc-3 - 将 HtmlAttributes 添加到模板

c# - HttpConfiguration.get_ServiceResolver() 缺失

c# - 带有 MEF 的 ASP.NET MVC4 : Requests to MEF Controllers Processed Serially

c# - 将多个属性的验证消息组合到一条消息中 asp.net mvc

asp.net-mvc - MVC html 帮助程序更改 hiddenfor 属性

javascript - 在 Razor 中,接受不带小数的整数

c# - 如何在自定义帮助程序中使用 Html.BeginForm?

c# - 验证登录表单 ASP.NET MVC

asp.net - web.config 编译/程序集元素有什么作用?