Search code examples
razorasp.net-mvc-4namespacesinclude

Why Razor doesn't see included namespace?


Now I have next and it works

@foreach (TestLogs.Repository.DatabaseModel.Platforms CurrentPlatform in     Model.ApplicationPlatforms)
    {
...
    }

I want to include TestLogs.Repository.DatabaseModel namespace to Razor's view. I open web.config at views folder and add line there

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
  <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="TestLogs.Repository.DatabaseModel" />
  </namespaces>
</pages>

But after that next construction doesn't work

 @foreach (Platforms CurrentPlatform in Model.ApplicationPlatforms)
    {
...
    }

What am I doing wrong?


Solution

  • Sorry for my stupid question. It works but my Visual Studio 2012 doesn't mark class name with cyan color as it usually does.

    My VS2012 ScreenCapture
    (source: piccy.info)