I have a problem using declarative helpers in the App_Code directory. I created a basic web page for my views, which has my localization method. I also have a set of listings for my helpers that revolve around CSS names.
For example, a DataRole is an enumeration related to the allowed CSS classes to display, and GetStr is my base class method for printing the label localization value:
@helper ReadOnlyColumns(DataRole role, string label, string contents)
{
<div class="@role">@GetStr(label)</div>
}
My web.config has a definition for the base page type and the correct namespaces to include. These settings work for views not in the App_Code directory.
Does anyone have any ideas how to create the App_Code directory? Should I put web.config in it? I'm at a loss.
I know that you can do @implements and @using, and that works. But I'm trying to create the basis for our software and I donβt feel that it is necessary to include things that will be used on absolutely every page that we write.
Edit, these are my web.config settings in the root and each view directory:
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="Company.Web.BaseWebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="Company.Web" />
<add namespace="Company.Web.Enums" />
</namespaces>
</pages>
</system.web.webPages.razor>
Thank,
Brad