13

All I want to do is include this:

@using MyProject.WebUI.Properties

Across all my views without having to type it in each View, is there a way to do that in the ViewStart or Web.Config? Thank you.

1 Answer 1

36

Add your namespace to the views web.config under the namespaces element:

<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="MyProject.WebUI.Properties" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

Note that you might have to close and reopen the view file that you want intellisense in for these changes to take affect.

Sign up to request clarification or add additional context in comments.

3 Comments

@napspinksi make sure the web.config you are updating is the one in Views folder
Thanks! Any idea how to get it included in intellisense?
@amurra (and naspinki) I had to close the view file and then re-open it for intellisense to pick up the new namespace. (Visual Studio 2010)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.