开发者

Namespace removed in web.config not removed in a page with master

I have defined this in the web.config of a subdirectory

<namespaces>
   <remove namespace="App"/>
   <add namespace="Tom"/>
</namespaces>

App is imported in the parent web.config file, Tom and App have classes with the same names.

To avoid errors resulting from ambiguous class names I removed the App namespace from the sub-directory where the Tom namespace is used.

However the namespace App is still imported on content pages that have a master page outside the Tom directory. This causes the aforementioned errors.

Here is my dir structure

-Root Directory 
--Default.master
--web.config (App is added in w开发者_JAVA百科eb.config)
--Tom Sub-diretory
---web.config (App is removed in web.config)
---Content page that uses Default.master (Here is the problem)
---Page without master (Works OK)

Any solutions?


Suppose you have the following in the root web.config:

<namespaces>
    <add namespace="App" />
    <add namespace="Tom" />
</namespaces>

And in your sub web.config:

<namespaces>
    <remove namespace="App" />
    <add namespace="Tom" />
</namespaces>

There will be no problem to use the class in .aspx pages in the sub-folder even if they derive from a master page in the root folder but you won't be able to use it in the master page. In the root master page you will need to fully qualify the type: <%= App.DuplicateType %> or <%= Tom.DuplicateType %>.


What about explicitly prefix the usages with the namespace? That should always work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜