6
Please explain to serve Helper
on Asp.Net MVC.
I see many examples that contain Helper
. I have no idea what it is Helper.
And how to create Helper ?
6
Please explain to serve Helper
on Asp.Net MVC.
I see many examples that contain Helper
. I have no idea what it is Helper.
And how to create Helper ?
5
Please explain to serve Helper on Asp.Net MVC.
Helper is a static class, outside the group of Controllers, which has replicable logic for the rest of the system.
By "replicable logic", it is any and all logic that is used in two or more places of the system. There are several examples here on the site.
Some examples of Helpers common:
HtmlHelper
, UrlHelper
).And how to create Helper?
Basically, as a common static class, in a namespace proper to it. For example:
namespace MeuProjeto.Helpers
{
public static class MeuHelper
{
public static String MetodoDoHelper1() { ... }
public static int MetodoDoHelper2() { ... }
public static void MetodoDoHelper3() { ... }
}
}
Use:
var retornoString = MeuHelper.MetodoDoHelper1();
var retornoInt = MeuHelper.MetodoDoHelper2();
MeuHelper.MetodoDoHelper3(); // pode não retornar valor, se for o caso.
Browser other questions tagged asp.net-mvc-5
You are not signed in. Login or sign up in order to post.
You’ve helped me so much, thank you !
– Matheus Miranda
I confess that a question like this was missing even. I hope to have helped :)
– Leonel Sanches da Silva