Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing ASP.NET MVC default folder structure

Tags:

asp.net-mvc

Is it possible to change around the folder organization to the following and still have MVC work.

P1

  • Controllers
  • Models
  • Views

P2

  • Controllers
  • Models
  • Views

etc..

like image 349
Arron S Avatar asked Feb 02 '26 10:02

Arron S


2 Answers

This looks a lot like the new feature area's which is available in MVC 2 though it is currently in preview and will be release with VS 2010.

If you want to do it yourself without using areas then check out this article on view engines

like image 193
Paul Creasey Avatar answered Feb 04 '26 00:02

Paul Creasey


as said before, the Areas feature is what you are looking for. If you are using vs2010, then although you have MVC2, you don't have the tools for creating the areas - these are only available on vs 2008, when you install the MVC2 rc

to make it happen follow the instructions at the following link: http://msdn.microsoft.com/en-us/library/ee671793%28VS.100%29.aspx as you can see the menu options are missing so:

  1. download the example project from there.
  2. build the directory structure at your solution according to the example
  3. change the AreaRegistration.cs to match your area name
  4. add AreaRegistration.RegisterAllAreas(); at the RegisterRoutes function at the global.asax, right after the IgnoreRoute

NOTE: the namespaces shuold contain .Areas. for More explanations search at stackoverflow for asp-net-mvc-2-beta-single-project-area-registration-getting-http-404 (since this is the first time i post an answer - SO doesn't let me append more then 1 link, go fugure..)

Hope this helps

like image 30
Avi Pinto Avatar answered Feb 03 '26 23:02

Avi Pinto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!