System.Web.Mvc.HtmlHelper' does not contain a definition for 'ActionLink'

Don't forget that the first parameter only accepts string. It will show you this error if it's NOT.


Make sure you have the namespace for your extensions class included in your web.config. For example:

namespace MyProject.Extensions
{
    public static class LinkExtensions
    {
        //code
    }
}

In your site Web.config and/or Web.config located in your "Views" folder:

  <system.web>
    <pages>
      <namespaces>
        <add namespace="MyProject.Extensions" />
      </namespaces>
    </pages>
  </system.web>

Otherwise include a "using" block for the namespace at the top of your view page can work but for common namespaces I would do the above.

ASPX:

<%@ Import namespace="MyProject.Extensions" %>

RAZOR:

@using MyProject.Extensions

Add this using System.Web.Mvc.Html; on top of your file


Make sure that you have following using in your class file:

using System.Web.Mvc.Html;

This is needed because the HtmlHelper class is located in System.Web.Mvc namespace but the ActionLink extension method is located in System.Web.Mvc.Html namespace.