I built a small module in ASP.net MVC which consists of
- a javascript file
- a css file
- a razor partial view
- a c# model class
If I use the standard way to manage the files, I have to spread them in these folders:
- /Scripts
- /Content/css
- /View
- /Models
I know that MVC is for separating them and it’s fine for the application but i my case I would be happier to have all files somewhere together.
There are area’s in MVC but I think that’s to big for a small module. All I want is to build a small package in my application for the files of this module.
Any good approach for this? How do you handle this?
This is just the structure that the default asp.net mvc project template imposes.
You can have any structure you like, but I would recommend keeping your Views and Model separate.
Since our “Model” usually sits in a different assembly our MVC project structure is normally:
Again this is personal preference but I typically like to keep my static assets (css,images,scripts) under one directory.
You can of course separate things out even further. For example if we’re using a javascript plugin that has it’s own “core” css and images then we normally keep these together e.g.:
Of course as you split things out in this way it can become hard to manage. For this reason we use Client Dependency Framework. You could also try Cassette.