MVC view namespace issue - Razor engine

I added a link to System.Web.DataVisualization in my MVC project. Now when I try to add a namespace to my web.config, I get an error

CS0234: The type or namespace name 'DataVisualization' does not exist in the namespace 'System.Web.UI' (do you miss the assembly reference?)

So, I am trying to use the same in my controller. It works great.

using System.Web.UI.DataVisualization;

Then the same should work in my Razor view

So I'm trying to use this in my Razor view

@using System.Web.UI.DataVisualization;

This does not work again, giving me the same error

Why can I use the namespace in my controller and not in my views?

Did I miss something...

+5
2

, "System.Web.DataVisualization", "CopyLocal" true,

@using System.Web.UI.DataVisualization

Razor.

+7

, . . , Web.Config "Views" ( web.config).

<system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.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="System.Web.UI.DataVisualization.Charting" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>
0

All Articles