title: Custom controls with ASP.NET MVC Razor
body: <p>How can I use custom controls with ASPNET.MVC Razor?</p>
  
  <p>I want to use a custom control on a Razor view. for instance:</p>
  
  <pre><code>&lt;mycontrols:something&gt;@Model.MyVar&lt;/mycontrols:something&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;mycontrols:something myattribute="@Model.MyVar" /&gt;
  </code></pre>
  
  <p>Please note that my goal is to use only few controls derived from MvcControl, only for trivial repetive ui stuffs.</p>
  
  <p>I tried to find out a syntax similar to @Register to write on the top of the view, but without any success.</p>
  
  <p>Then I went to the web.config, adding </p>
  
  <pre><code>&lt;pages&gt;
     &lt;controls&gt;
        &lt;add tagPrefix="mycontrols" namespace="mynamespace" assembly="myassembly"/&gt;
     &lt;/controls&gt;
  &lt;/pages&gt;
  </code></pre>
  
  <p>but it looks like custom controls are ignored in rendering.</p>
  
  <p>Someone could help? </p>
  
  <p>...Might be it is a little bit old fashion, but sometimes also custom control could be useful to make your code cleaner!</p>