I basically followed this article: http://develoq.net/2011/how-to-create-custom-html-helpers-for-asp-net-mvc-3-and-razor-view-engine/
My HtmlHelper class is located in the root directory of my MVC project:
using System.Web.Mvc;
namespace MvcHtmlHelpers
{
public static class HtmlHelperExtensions
{
public static MvcHtmlString Hello(this HtmlHelper helper)
{
return new MvcHtmlString("Hello!");
}
}
}
If I reference it in a view: @using MvcHtmlHelpers;
I get intellisense and view code validates fine (no red underlines).
If I don't reference it in a View, but reference it in either one or both of the 2 web.config files, I don't get intellisense and @Html.Hello()
is now red underlined.
Now the best part is that when I run, it renders perfectly fine even if I don't have it referenced anywhere at all. Ideally, I would like to reference it once in the web.config
and get Intellisense in a view without referencing it in that view.
UPDATE: I guess something got cached somewhere. It does NOT render when it's not referenced anywhere. I'm sorry. I would still like to get Intellisense and validation in a view.