In the MVC folder structure, where should general class files reside? For example, I have a class that determines the right DataContext to use, so I'm not reinventing the wheel in each of my controllers. Should it live in the Controllers folder even though it's not a controller? Should it be with the Models because it's database related, even though it's not a model? Possibly the Views\Shared folder? Or is Content the catch-all folder for that kind of stuff? I'm sure I could put it anywhere, but I was wondering where the "right" place is.
If it could be useful by itself (think of a command line tool built around it), put it in the Models folder. If it is used only as a helper for controllers, put it in Controllers folder.
If you look at Rob's MVC Storefront: Separate class library project (like Commerce.MVC.Data)
It really depends on what it does, if it accesses data it should be in the Data Access Layer, otherwise you can put it in the controller folder.
dmajkic,
Why separate it out into its own area? If its BLL code it should be in the controller folder, if its DAL related item it should be in the Model. I can understand if a project gets huge and you want to create some subfolders, that shouldn't be an issue. But placing code in another tier really defeats the purpose of MVC don't you think?
It's not a controller, content or a view, so don't use those. It sounds most closely related to your model, so you could put it in model under a subfolder called "Helpers" or "Utility" or some such. Or you can add another top level folder called Services and put it there. That's where I put all my app logic, the middle man between the controllers and the model.
Have a separate DataAccess assembly, make that class internal and call it DataContextFactory.