Accessing ActionLink() from within a HtmlHelper extension

If you are developing a HtmlHelper extension and need to access ActionLink() or any other of the out-of-the-box extensions for that matter, all you need to to is import the right namespace and then you can use the HtmlHelper instance that’s been passed as an argument to create the extension method.

using System.Web.Mvc.Html;

public static string Example(this HtmlHelper helper)
{
   helper.ActionLink(...)
}

The trick here really is to not forget the import of the namespace because otherwise the extension will not be available and if you use any refactoring tools like Resharper, at least for now, it doesn’t pick up on the missing reference and leaves you a bit helpless.