How to avoid placing <% @ Import namespace = "MyProject.Helpers"%> on top of each view?
I am working on my first asp.net mvc application, and I use custom helpers such as Html.Label () from the example on the official website.
To access Html.Label I have to post
<%@ Import Namespace="BRG.Helpers" %>
at the top of each species.
Is there any way to avoid this? I read somewhere that someone mentioned web.config, but I cannot find it anywhere.
Can anybody help me?
You can add a namespace to web.configin configuration\system.web\pages\namespaces, for example:
<configuration>
<system.web>
<pages ...>
<controls ... />
<namespaces>
<add namespace="BRG.Helpers" />
</namespaces>
</pages>
</system.web>
</configuration>
You can do this either in the root directory web.configor in the directory Views.