MVC3 - Where to place custom attribute classes

Shawn picture Shawn · Aug 23, 2011 · Viewed 7.7k times · Source

I am delving into custom validation attributes and am curious to know how others structure the projects. Where do you typically store custom attributes?

My first thought was to simply create a new folder and be done with it.

Any suggestions?

Answer

Darin Dimitrov picture Darin Dimitrov · Aug 23, 2011

My first thought was to simply create a new folder and be done with it.

It would depend on the nature of those attributes and what thety are supposed to do. For example if they are validation attributes you could put them into a Validators folder. If they are action filters you could put them in the ActionFilters folder, etc... so your initial thought is correct. Personally I group those attributes based on their function and place them in a separate folder which indicates this function.