2

I've created an MVC 2 project with nested areas, such as:

Areas
-->A
   -->C
      --> Controllers
      --> Models
      --> Views
   -->D
      --> Controllers
      --> Models
      --> Views
   -->Controllers
   -->Models
   -->Views
-->B
   -->E
      --> Controllers
      --> Models
      --> Views 
   -->F
      --> Controllers
      --> Models
      --> Views 
   -->Controllers
   -->Models
   -->Views
Controllers
Models
Views

This works and correctly finds all the controllers/views as long as I modify the area names in the area registration files to be "A/C" instead of simply "C". However, the default behavior for Visual Studio is not correct for this project layout. If I add an action method to a controller inside "A/C/Controllers", right-click and choose "Add View", VS creates the folder and file "A/Views/{controller}/{action}.aspx" instead of "A/C/Views/{controller}/{action}."

Is there a way to change this default behavior? Perhaps create an add-on that overrides the default behavior? I'm pretty new to .NET and VS 2010 so any help is greatly appreciated.

newguy
  • 101
  • 1
  • Could you clarify the structure of your project (what you typed in makes no sense) as well as what behavior you would expect. – marcind Sep 08 '10 at 03:38
  • Interesting, I've never even used the Add View. We've built a 300 view app and always just copy and paste an existing basic template view and modify accordingly. – Beep beep Sep 08 '10 at 05:05
  • So the diagram represents an MVC 2 project with 2 Areas, A and B. Underneath A are two more areas, C and D, and underneath B are two areas, E and F. – newguy Sep 08 '10 at 11:42
  • Let's say I add a Controller called "Home" to the "Controllers" folder in Area "C". I then add an action method named "List" to this controller. Currently if I use the VS default for adding a view for this method, it creates a folder called "Home" under the A/Views and an ASPX file called List.aspx under A/Views/Home. The behavior I want, however, for the "Home" folder to be created under A/C/Views and the corresponding ASPX file added there. – newguy Sep 08 '10 at 11:46
  • Jess, thanks for you comment. I have a feeling I'll simply do the same thing (copy and paste) but I wanted to understand if the default VS behavior was easy to modify first. – newguy Sep 08 '10 at 11:47
  • this would be done via route mapping – cpoDesign Jul 05 '11 at 12:27

0 Answers0