How to customize directory structure in ASP.NET MVC?

北城余情 提交于 2019-12-11 07:58:39

问题


The project I'm starting to work at will have several dozens of controllers, so it would be nice to structure them into logical directories and respective namespaces, like "Controllers/Admin/", "Controllers/Warehouse/Supplies/", etc.

Does ASP.NET MVC support nested controller directories and namespacing? How do I manage routes to those controllers?


回答1:


You can put the controllers anywhere; routes do not depend on where a controller is stored. It will be able to find any class that implements IController within your application.

I usually keep my controllers in a separate project, f.ex a MyProject.Frontend project, alongisde a MyProject.Frontend.Application project which is the actual entrypoint web project with the views etc.



来源:https://stackoverflow.com/questions/119388/how-to-customize-directory-structure-in-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!