asp.net mvc 4 - ASP:NET MVC4 url routing for controllers with the same name in different namespaces -




in asp.net mvc4 web project, have many controllers , want put them subdirectories under folder "controllers". controllers have same name due major jobs, put under different subdirectories, means different namespaces. want url routing controllers. how can make routing consider namespaces controllers same name exist? show code how in global.asax file?
lot.

you need several maproute-s - @ lease 1 each namespace.

 // match controllers in first namespace  routes.maproute(     name: "namespace1routes",     url: "path1/{controller}/{action}/{id}",     defaults: new { controller = "home", action = "index", id = urlparameter.optional },     namespaces: new[] { "my.namespace1" }  );   // match controllers in second , third namespaces  routes.maproute(     name: "namespace2routes",     url: "path2/{controller}/{action}/{id}",     defaults: new { controller = "home", action = "index", id = urlparameter.optional },     namespaces: new[] { "my.namespace2", "my.namespace3" }  ); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -