Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put a simple Class in an MVC project?

Tags:

asp.net-mvc

Ok, this is possibly borderline-subjective, but I wonder where one would put a simple class that does something within an ASP.net MVC project? I mean a class like the Base36 De/Encoder, that is neither Model nor Controller. Should this always go into a separate Class Library Assembly, or do such Classes have a place within the MVC Web Application project?

And yes, I know that it probably does not really matter, I'm just possibly a bit over careful to learn a new technology the "right" way from the beginning.

like image 445
Michael Stum Avatar asked Oct 20 '08 18:10

Michael Stum


People also ask

How do you add class to a model?

Adding Model ClassesIn Solution Explorer, right click the Models folder, select Add, and then select Class. Enter the class name "Movie".

Why we need areas in MVC?

Area allows us to partition the large application into smaller units where each unit contains a separate MVC folder structure, same as the default MVC folder structure. For example, a large enterprise application may have different modules like admin, finance, HR, marketing, etc.

What goes in the model in MVC?

An MVC model contains all of your application logic that is not contained in a view or a controller. The model should contain all of your application business logic, validation logic, and database access logic.


1 Answers

I personally put such classes in some common "utils" assembly. Not only does it avoid junking up your MVC project, but such helper classes often find their way into other projects I work on.

like image 142
Jason Whitehorn Avatar answered Sep 29 '22 05:09

Jason Whitehorn