Pregunta

Me gustaría crear un método de ayudante estático que pueda llamar desde una vista.

¿Es posible que un método auxiliar tenga acceso al ViewContext actual sin necesidad de pasar explícitamente el ViewContext al método como parámetro?

Algo como httpcontext.current excepto para ViewContext.

¿Fue útil?

Solución

public static class XTenshuns
{
    public static string MyHtmlHelper(this HtmlHelper helper)
    {
        // it's right here -> helper.ViewContext
    }
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top