1

So I understand that namespaces defined in ~/Views/web.config will add those namespaces for all views. But why is there also a namespace section in ~/web.config in the root folder`?

1

1 Answer 1

1

Every view will inherit the namespaces in ~/web.config. Potentially you could build different namespace hierarchies using different levels of config files.

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

4 Comments

So I can remove namespaces from ~/web.config if they are also in ~/Views/web.config?
Yes. Altough there are cenarios where you would want them to be in the root config file (for instance if you would need to change them with configuration transformations). My experiences with adding and removing namespaces in config files have shown that adding a namespace will take some time to be "recognized" by VS.
1. What do you mean with for instance if you would need to change them with configuration transformations? And 2. it is enough to do a clean build and reopen the chtml file.
I can imagine a situation where you would want to run one set of helpers in development for debugging the helpers side by side with you MVC app and another one in production where helepers could be shared between multiple apps and located in GAC. Configuration transformations could help you accomplish that. As of #2 in theory it should be enought, but Intellisense cache (where the helpers are living to provide you with development time support) has been somewhat mysterious to me :)

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.