tags:

views:

126

answers:

1

Hi,

I'm working on my first asp.net mvc application and I'm using custom helpers like the Html.Label() from the example on the official site.

For having access to Html.Label, I have to place

<%@ Import Namespace="BRG.Helpers" %>

at the top of every view.

Is there a way to avoid having to do that? I've read somewhere someone mentioning something about the web.config, but I can't find it anywhere..

Anyone can help me?

+6  A: 

You can add the namespace to your web.config in configuration\system.web\pages\namespaces like:

<configuration>
    <system.web>
        <pages ...>
            <controls ... />
            <namespaces>
                <add namespace="BRG.Helpers" />
            </namespaces>
        </pages>
    </system.web>
</configuration>

You can do this in either the root web.config or the one in the Views directory.

Garry Shutler
Exactly what I needed. Thanks Garry.
Thomas Stock
It doesn't work for me. I'm using mvc 2.
denis_n
Probably it works, but I was using portable areas from MvcContrib and it didn't work.
denis_n