I would like to group all my Controllers with related Views in separate folders. How can I achieve this?
views:
107answers:
1
                +4 
                A: 
                
                
              - Don't.
 - But if you must, write a custom ViewEngine to locate the views. I wrote a (now out of date) example here. ViewLocator has since been renamed to ViewEngine.
 - See (1)
 
Update: If you actually meant you're looking for an "areas" feature, try this.
                  Craig Stuntz
                   2009-03-02 01:46:28
                
              I think he means the same thing as areas in monorail, which there is nothing wrong with so I have no idea why you say don't.
                  Mike Geise
                   2009-03-02 06:56:48
                Areas don't work that way; perhaps it's what he really meant, though. See http://blog.codeville.net/2008/11/05/app-areas-in-aspnet-mvc-take-2/ for a good design for that.
                  Craig Stuntz
                   2009-03-02 12:43:00
                I definitely meant the concept of Areas highlighted by Phil Haack.
                  gugulethun
                   2009-03-02 13:17:03
                OK, then see the update / link.
                  Craig Stuntz
                   2009-03-02 13:56:53
                Why 1?, why don't?
                  Paco
                   2009-03-04 22:45:47
                Paco, Views shouldn't know about Controllers, so they should be in different namespaces, and hence different folders.
                  Craig Stuntz
                   2009-03-05 01:32:06
                But views shouldn't know about each other too.
                  Paco
                   2009-03-05 09:10:23
                Um, true, though I've never actually seen anyone have a problem with that. Making controller<->view dependencies incorrect is *common*, though.
                  Craig Stuntz
                   2009-03-05 12:32:23
                My views depend on controller because I use Html.ActionLink or Html.BeginForm. I don't understand what's bad about that.
                  Paco
                   2009-03-05 17:57:25
                That isn't a dependency. That's a string. Dependencies are different.
                  Craig Stuntz
                   2009-03-05 18:17:36
                I consider something depending on something else a dependency. A form is posted to a specific controller action and it doesn't matter if a string or generic with lambda is used.
                  Paco
                   2009-03-05 18:47:50
                I'm not sure yet if I want to create a directory with controller/viewmodel/view or a directory per type like the default
                  Paco
                   2009-03-05 18:48:35
                My $0.02: Use the default unless you have a *really* good reason not to. About dependencies: I think we'll just have to disagree on that.
                  Craig Stuntz
                   2009-03-05 19:12:52