Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.net MVC project structure

I have created the following project structure for my new asp.net mvc project any I was after some feedback as how other people are structuring their projects and if I would improve mine...

Here is what I have so far:

+Assets
-+Images 
-+Scripts 
-+Stylesheets 
-+...              'More things like the above here
+Controllers 
-+Support
--+Actions         'Any custom action classes
--+Controllers     'Base controller classes
+Models
-+Domain           'Contains any class that specialise view specific domain logic
--+UrlProcessing   'Encoding/decoding business entities as URL parts 
--+...             'More things like the above here
-+Views            'Contains view models
--+Support
---+Views          'Base classes for any view models
+Support
-+Application      'Global application interface classes (i.e. class that wraps the function of the global asax)
-+Configuration    'Typed config classes
-+Helpers          'Where you put additional html helper classes, etc
-+Services
--+Bootstrap       'Tasks that run on mvc start-up that are specific to the MVC project
--+Inversion       'Specific IoC registration registrations for this project 
--+...             'More things like the above here
+Views
-+Home
-+Shared 
-+...              'More things like the above here

Cheers Anthony

like image 390
vdh_ant Avatar asked Jul 07 '09 00:07

vdh_ant


1 Answers

MVC Site
app - all static files
--common
----css
------styles-most-pages-use.css
----imgs
------images-most-pages-use.png
----js
------your-custom-lib.js
--files
----release_notes.md
----release_notes.html
--pages
----signin
------signin.css
------logo.png
------signin.js
----dashboard
------dashboard.js
--vendors
----jquery
------jquery.1.11.1.js
-_references.js

Controllers - only thin controllers, just code to call your core library functions
Models - only models that are used to display the view
Views - only client code like html, razor, css, etc

Core library
Basically all code...data access, custom attributes, utilities, etc. Separating out the core code to just a library is handy for many reasons. Your logic is not tied to just a web site now. If I need to I can build a quick front end in WinForms to test some logic or I could use the same functions in your data access layer to build a admin front end for the database.

I find this structure to be the simplest and most flexible for me.

Update
I'v updated the static content file structure to be more flexible and modern. I came up with this structure when working with AngularJS. I eventually moved on to RactiveJS. After moving to RactiveJS the same structure worked really well.

Update 8-21-15 I'v been working on larger projects lately and have been separating the Core library out to its own Visual Studio Project. This makes it flexible when using SVN Externals. I can use the same library across different projects and only need to do a SVN Update to get the changes. Also broke out the MVC Site in its own Project also.

like image 92
Donny V. Avatar answered Sep 22 '22 14:09

Donny V.