ASP.NET MVC: Namespaces in Routes

I have a small problem, I can not find the documentation on the namespaces parameter for MapRoute. Can anyone explain how I should use this?

I want to map ~ / Controllers / Projects / ProjectController.cs with this URL ~ / Projects / , but I also have other controllers in ~ / controllers / Projects that I want to map to other URLs. Therefore, I need to add a namespace for these URLs. How?

+6
namespaces asp.net-mvc routing
source share
2 answers

The namespaces parameter allows you to specify where the infrastructure should look for additional types of controllers, by default, mvc will look for ALL classes in the executing assembly (site project), and those that implement IController become candidates. Basically you can put controllers in any number of subfolders if you want if they are part of the asp.net mvc project ..

The main use of the namespaces parameter is if you want to store controller classes in an external assembly, in which case you can specify the namespace in which these controllers are located.

+7
source share
0
source share

All Articles