How do I organize controllers and views in namespaces or subfolders?

I am working on ASP.NET MVC Application. The application is divided into a dozen "sections", each of which has several tasks that the user can perform. Many of these subtasks deserve their own controller, I don't like kitchen sink controllers.

I want to organize my controllers by adding a namespace hierarchy:

Foo.SubFoo1.List

Foo.SubFoo2.List

and etc.

I figured out how to create routing rules, I just don't know how to wire the correct view. The MVC framework does not affect my controller parent space in the algorithm when it looks for a view:

Foo.SubFoo1.List ==> MVC is looking for Views \ SubFoo1 \ List.aspx , but I want it to look for Views \ Foo \ SubFoo1 \ List.aspx

Suggestions?

0


source to share


1 answer


The literal answer to your question is "override the default ViewEngine", but it looks like you are really looking for "areas."



+4


source







All Articles