Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom html helpers in MVC 4

I created the helper class

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

And added the namespace to webconfig <add namespace="SEM.API.Helpers" /> but I still getting an error:

CS1061: "System.Web.Mvc.HtmlHelper"

It isn't solved after a lot of rebuilds

like image 306
Dmitriy Romanov Avatar asked Jun 12 '12 14:06

Dmitriy Romanov


1 Answers

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

Make sure you did this in ~/Views/web.config and not in ~/web.config.

Another thing to try is to add the @using directive to your view:

@using SEM.API.Helpers
@Html.BuildSomething()
like image 75
Darin Dimitrov Avatar answered Jan 05 '23 06:01

Darin Dimitrov