2

In my razor view I name a include namespace like this: @using Resources = Project.Resources. I want to include this namespace in every view. So I went to the Web.config of my views folder and added this:

<configuration>
  <system.web.webPages.razor>
    <namespaces>
      <add namespace="Project.Resources" />
    </namespace>
  </system.web.webPages.razor>
</configuration>

Is there a way to add a name to this namespace? So I can type @Resource.Label in my views?

2 Answers 2

4

i have investigated for about half an hour(actually much more time). you can find answer here, as danludwig mentioned. what you are doing is right, just save your project&solution, and restart your visual studio. i have tried it, works fine. hope help.

<add namespace="myNameSpace=Ioc.Model" />
Sign up to request clarification or add additional context in comments.

3 Comments

Adding the namespace is not the problem. The problem is adding the namespace using a name in the web.config.
real sorry for taking no notice of this requirement. i have updated my post.
you may have to re-add the reference and restart visual studio, clean/rebuild and it works (vs2013)
1

I know this is an old question but, There is also another way for adding a named namespace:

<configuration>
    <system.web.webPages.razor>
        <namespaces>
            <add namespace="Projects = Project.Resources" />
        </namespace>
    </system.web.webPages.razor>
</configuration>

and as you mentioned, you can type @Resource.Label your views.

Comments

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.