Reputation: 67
I have created a folder admin inside controller folder and wrote few controllers in it. I want to access all functions in that controllers in that folder by a url like abc.com/admin//.
I can get it working directly when its put directly in controller folder.
EDIT
WHAT HAVE YOU TRIED?
Upvotes: 3
Views: 490
Reputation: 311835
Add a route for the admin controllers in your route config if you want to support that path in the URL. Something like:
routes.MapRoute(
name: "Admin",
url: "admin/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
But @DotNetDreamer is right that Areas are a better solution for the admin functionality of your site.
Upvotes: 1
Reputation: 7752
Well, i would suggest, rather than just creating a folder and create controllers inside of it. You should create an Area
When you create an Area
in asp.net mvc, it will automatically create folders(controller, model etc) for you. And the routing setup as well.
For more info, please visit
http://www.codeguru.com/csharp/.net/net_asp/mvc/article.php/c20227/Using-Areas-in-ASPNET-MVC-Application.htm
Upvotes: 1