This is a migrated thread and some comments may be shown as answers.

Namespace Issue MVC 3 Razor

1 Answer 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Schalk
Top achievements
Rank 1
Schalk asked on 20 Mar 2011, 10:55 AM
Good day,
I'd like to point out an issue in the visual studio templates for MVC 3 Razor in the 2011 Q1 release.

The namespace add in web.config
<add namespace="Telerik.Web.Mvc.UI" />
should be added in the ~/Views/Web.Config rather that in ~/Web.Config like so
<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="Telerik.Web.Mvc.UI" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>
which means the sections (added in ~/Web.Config isn't required.

Also, when using additional/custom helpers, their namespace reference should be added like above to provide global access in razor views to their namespaces instead of having to use @using *.*.Helpers or similiar syntax in every view.

Good work on the new release and happy coding!

1 Answer, 1 is accepted

Sort by
0
norm
Top achievements
Rank 1
answered on 17 Jun 2011, 07:02 PM
Thank you Schalk!
Tags
General Discussions
Asked by
Schalk
Top achievements
Rank 1
Answers by
norm
Top achievements
Rank 1
Share this question
or