Please explain to serve Helper
in Asp.Net MVC.
I see many examples that contain Helper
. I have no idea what Helper is.
And how to create Helper?
Please explain to serve Helper
in Asp.Net MVC.
I see many examples that contain Helper
. I have no idea what Helper is.
And how to create Helper?
Helper is a static class, outside of the Controllers group, which has replicable logic for the rest of the system. >Please explain to serve Helper in Asp.Net MVC.
By "replicable logic", it is any logic that is used in two or more places in the system. There are several examples here on the site .
Some examples of common Helpers :
HtmlHelper
", UrlHelper
). And how to create Helper?
Basically, as a common static class, in a namespace itself for this. For example:
namespace MeuProjeto.Helpers
{
public static class MeuHelper
{
public static String MetodoDoHelper1() { ... }
public static int MetodoDoHelper2() { ... }
public static void MetodoDoHelper3() { ... }
}
}
Usage:
var retornoString = MeuHelper.MetodoDoHelper1();
var retornoInt = MeuHelper.MetodoDoHelper2();
MeuHelper.MetodoDoHelper3(); // pode não retornar valor, se for o caso.