title: Where should I place Declarative HTML helpers in ASP.NET MVC 3
body: <p>I'm trying to make a declarative HTML Helper as specified in <a href="http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx" rel="noreferrer">ScottGu's Razor post</a>, but I'm not having much luck. I tried putting a Helpers.cshtml file with a DateTimeHelper in Views/Helpers but it wouldn't pick it up, so I tried in App_Code as per <a href="http://weblogs.asp.net/scottgu/archive/2010/10/06/announcing-nupack-asp-net-mvc-3-beta-and-webmatrix-beta-2.aspx#7625216" rel="noreferrer">the MVC 3 Beta post</a>. Now it picks it up, but when I try to use it in a file like so:</p>
  
  <p>@DateTimeHelper(DateTime.Now)</p>
  
  <p>The compiler complains that DateTimeHelper doesn't exist.</p>
  
  <p>Some weird things:
  If I rename the file to DateTime.cshtml, I get a different error, something about the particular code in my helper.</p>
  
  <p>For completeness' sake, here's the helper's code:</p>
  
  <pre><code>@helper DateTimeHelper(DateTime t, bool longDate = true, bool showTime = true, bool longTime = true) {
      &lt;time datetime='@t.ToUniversalTime()'&gt;
          @if(longDate) {
              if(showTime) {
                  if(longTime) {
                      @t.ToLongDateString() @t.ToLongTimeString();
                  } else {
                      @t.ToLongDateString() @t.ToShortTimeString();
                  }
              } else {
                  @t.ToLongDateString()
              }
          } else {
              if(showTime) {
                  if(longTime) {
                      @t.ToShortDateString() @t.ToLongTimeString();
                  } else {
                      @t.ToShortDateString() @t.ToShortTimeString();
                  }
              } else {
                  @t.ToShortDateString()
              }
          }
      &lt;/time&gt;
  }
  </code></pre>
  
  <p>The helper is used in a certain view like this:</p>
  
  <pre><code>@model dynamic
  
  &lt;div&gt;
      &lt;p&gt; The current time is @DateTimeHelper(DateTime.Now)&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>