asp.net mvc - subfolders

后端 未结 4 534
眼角桃花
眼角桃花 2021-01-04 11:17

How does the new Microsoft asp.net mvc implementation handle partitioning your application - for example:

--index.aspx
--about.aspx
--contact.aspx
--/feature         


        
4条回答
  •  情话喂你
    2021-01-04 11:44

    There isn't any issues with organizing your controllers. You just need to setup the routes to take the organization into consideration. The problem you will run into is finding the view for the controller, since you changed the convention. There isn't any built in functionality for it yet, but it is easy to create a work around yourself with a ActionFilterAttribute and a custom view locator that inherits off ViewLocator. Then when creating your controller, you just specify what ViewLocator to use, so the controller knows how to find the view. I can post some code if needed.

    This method kind of goes along with some advice I gave another person for separating their views out for a portal using ASP.NET MVC. Here is the link to the question as a reference.

提交回复
热议问题