strike_noir
strike_noir

Reputation: 4174

what folder to put site-wide functions/classes in ASP.NET MVC

NET MVC

and i want to create a class to contain site wide functions for my application

what is the best practice to do this? where should i create the class ? in what folder? should i create a new folder?

edited: I need a function that return base uri, and it have be available to call from any controller. A date formatting function, or any other simple logic , but is going to be used repetitively

Upvotes: 1

Views: 821

Answers (2)

Kane
Kane

Reputation: 16812

As commented on by @Charlino you have a wide variety of choices. Personally I would structure your MVC solution with 2 projects. One project for your UI and one project for everything else which would include the “common” functions you’re describing. You can separate the "everything else" into many smaller assemblies however my personal preference is to have fewer assemblies. I always find it easier to work with fewer assemblies. If you use good coding principles (like SOLID) then it shouldn't matter if you use 2 or 20 assemblies.

Jimmy Bogard (author of Automapper) has written an excellent article on how he structures his solutions.

Upvotes: 1

mark vanzuela
mark vanzuela

Reputation: 1391

It depends on what your function contains. If its like a common helper/utility function that should be available in the whole application, i would put it in Helpers folder. Just my .02 cents though.

Upvotes: 0

Related Questions