title: Why am I getting "The directive 'control' is unknown" error in ASP.NET MVC?
body: <p>I'm working on an editor page for a project in ASP.NET MVC. I would like to use a control for both the create page and the edit page so I don't have to duplicate code. I've set up an <code>EditorTemplates</code> folder inside <code>/Views/Shared</code> to hold my templates. And I've placed a .ascx file in there called <code>ArticlePresentation.ascx</code>.</p>
  
  <p><code>ArticlePresentation.ascx</code> looks like this:</p>
  
  <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;genesis.Core.Presentation.ArticlePresentation&gt;" %&gt;
  
  Testing the control
  </code></pre>
  
  <p>My <code>Edit.aspx</code> view looks like this:</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/genesis.Master" Inherits="System.Web.Mvc.ViewPage&lt;genesis.Core.Presentation.ArticlePresentation&gt;" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"&gt;
      Edit
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
  
      &lt;h2&gt;Edit&lt;/h2&gt;
      &lt;% using (Html.BeginForm()) {%&gt;
          &lt;%: Html.ValidationSummary(true) %&gt;
          &lt;%: Html.EditorFor(ArticlePresentation =&gt; ArticlePresentation)%&gt;
      &lt;% } %&gt;
  
      &lt;div&gt;
          &lt;%: Html.ActionLink("Back to List", "Index") %&gt;
      &lt;/div&gt;
  
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>I can build the site without getting any errors, but, when I run the site and browse to the editing page I get this error:</p>
  
  <blockquote>
    <p>System.Web.HttpParseException was unhandled by user code</p>
  
  <pre><code> Message=The directive 'control' is unknown.
  
   Source=System.Web
  
   ErrorCode=-2147467259
  
   WebEventCode=0
  
   FileName=C:&lt;path to folder&gt;asp.net mvc\genesis\genesis\Views\Shared\EditorTemplates\ArticlePresentation.aspx
  
   Line=2
  
   VirtualPath=/Views/Shared/EditorTemplates/ArticlePresentation.aspx
  
   StackTrace:
  
        at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
  
        at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)
  
        at System.Web.UI.TemplateParser.ParseInternal()
  
        at System.Web.UI.TemplateParser.Parse()
  
        at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()
  
        at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
  
        at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
  
        at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
  </code></pre>
    
    <p>etc... etc...etc...</p>
  </blockquote>
  
  <p>I've searched google looking for solutions, but everything I've found so far relates to having the control in an aspx page rather than a ascx page.</p>
  
  <p>Does anyone know what could be causing this error?</p>