title: 'System.Web.Webpages.Html.Htmlhelper' does not contain a definition for 'Sitecore'
body: <p>I'm getting this error in Visual Studio, when I use <code>@Html.Sitecore</code>:</p>
  
  <blockquote>
    <p>'System.Web.Webpages.Html.Htmlhelper' does not contain a definition for 'Sitecore' and the best extension methods overload 'Sitecore.Mvc.HtmlHelperExtensions.Sitecore(System.Web.Mvc.HtmlHelper)' has some invalid arguments.`</p>
  </blockquote>
  
  <p>However, once deployed it does run without any problems.</p>
  
  <p>I'm using Sitecore 7.2 with MVC 5.1.</p>
  
  <p><img src="https://i.stack.imgur.com/yTzqk.png" alt="enter image description here"></p>
  
  <p>Articles that I've read that deal with similar error messages, talk about the <code>system.web.webPages.razor</code> section of the <code>Views</code> folder <code>web.config</code> file. This is how it appears in my solution.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;system.web.webPages.razor&gt;
  &lt;host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
  &lt;pages pageBaseType="System.Web.Mvc.WebViewPage"&gt;
    &lt;namespaces&gt;
      &lt;add namespace="System.Web.Mvc" /&gt;
      &lt;add namespace="System.Web.Mvc.Ajax" /&gt;
      &lt;add namespace="System.Web.Mvc.Html" /&gt;
      &lt;add namespace="System.Web.Routing" /&gt;
    &lt;/namespaces&gt;
  &lt;/pages&gt;
  </code></pre>
  
  <p></p>
  
  <p>Originally I thought I'd just need to restart VS, but that didn't work. Does anyone have any suggestions.</p>
  
  <p><strong>EDIT</strong>
  This is the standard Sitecore 7.2 installation, and so has the following binding redirects:</p>
  
  <pre><code>  &lt;dependentAssembly&gt;
      &lt;assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" xmlns="urn:schemas-microsoft-com:asm.v1"/&gt;
      &lt;bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.1.0.0" xmlns="urn:schemas-microsoft-com:asm.v1"/&gt;
    &lt;/dependentAssembly&gt;
    &lt;dependentAssembly&gt;
      &lt;assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" xmlns="urn:schemas-microsoft-com:asm.v1"/&gt;
      &lt;bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" xmlns="urn:schemas-microsoft-com:asm.v1"/&gt;
    &lt;/dependentAssembly&gt;
  </code></pre>
  
  <p>Also when looking at the output from visual studio there is an additional error that I didn't spot before:</p>
  
  <p><code>Instance argument: cannot convert from 'System.Web.WebPages.Html.HtmlHelper' to 'System.Web.Mvc.HtmlHelper'</code></p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>I no longer think this is a Sitecore MVC issue. I get a similar error with <code>@Html.ActionLink("xxx", "xxx")</code>. Other people have seen this issue in VS2012, but  I'm using 2013.</p>
  
  <p><strong>EDIT 3</strong></p>
  
  <p>There are now quite a few answers to this question. I recommend trying each of them as it seems there are numerous reasons this error might occur.</p>