ASP.NET MVC's MapRoute method has a parameter named namespaces.
From looking in the code, I see that this parameter is saved in the Route object
in DataTokens["Namespaces"].
It seems to me that it has some meaning... anyone knows what is it for?
You can use the namespace parameter for mapping routes to specific Areas.
If you have one route for HomeController for example. You need to add that route twice with different namespaces otherwise they will end up in the same Controller
* REMEMBER TO MARK THE ANSWER TO YOUR QUESTION * .NET Developer (ASP.NET, MVC, WPF) MCTS .NET 4 (Web, WCF)
Blog | Twitter
Datak tokens are simply additional set of extra configuration that will be passed to the route handler.
one important data token is namespace. which is used for giving prirority to a controller.
For example if you have two controller of same name but in different namespace, then from namespace data token you can set proririty to one controller.
Steve
if you choose to give multiple controller classes the same name,even if they are in different namespaces. DefaultControllerFactory won’t know which one to instantiate, so it will simply throw an InvalidOperationException, saying “The controller name is ambiguous.”
To deal with this, you must either avoid having multiple controller classes with the same name, or you must give DefaultControllerFactory some way of prioritizing one above the others. There are two mechanisms for defining a priority order.
Steve
You can also prioritize a set of namespaces to use when handling a particular RouteTable.Routes entry. For example, you might decide that the URL pattern admin/ {controller}/{action} should prefer to pick a controller class from the MyApp.Admin.
Controllers namespace and ignore any clashing controllers that are in other namespaces.
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Marked as answer by Shayke on May 21, 2010 07:00 AM
Shayke
Member
18 Points
28 Posts
What is MapRoute namespaces parameter for?
May 19, 2010 10:54 AM|LINK
ASP.NET MVC's MapRoute method has a parameter named
namespaces. From looking in the code, I see that this parameter is saved in theRouteobject inDataTokens["Namespaces"].It seems to me that it has some meaning... anyone knows what is it for?
Thanks,
Shay.
maproute
Visual C#/IronRuby MVP
http://www.ironshay.com
Twitter: http://twitter.com/ironshay
Knecke
Contributor
3712 Points
838 Posts
Re: What is MapRoute namespaces parameter for?
May 19, 2010 10:58 AM|LINK
You can use the namespace parameter for mapping routes to specific Areas.
If you have one route for HomeController for example. You need to add that route twice with different namespaces otherwise they will end up in the same Controller
.NET Developer (ASP.NET, MVC, WPF) MCTS .NET 4 (Web, WCF)
Blog | Twitter
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: What is MapRoute namespaces parameter for?
May 19, 2010 03:20 PM|LINK
Datak tokens are simply additional set of extra configuration that will be passed to the route handler.
one important data token is namespace. which is used for giving prirority to a controller.
For example if you have two controller of same name but in different namespace, then from namespace data token you can set proririty to one controller.
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD