Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One method accessible to all controllers - where to put it?

Tags:

asp.net-mvc

In MVC, for example I have 5 different controller files. In all of them I have a method for saving an image. Is there a way to put this method on one place and every controller method to access it, instead of writing it in every controller? I tried

 MyController.MyMethod();

But the Intellisence isn't showing it after I write the dot.

like image 765
petko_stankoski Avatar asked Dec 04 '22 04:12

petko_stankoski


1 Answers

Put it in a utility class and make it static. From your controllers all you need to do is something like:

Utility.SaveImage(...);
like image 186
Icarus Avatar answered Feb 12 '23 08:02

Icarus