Growing with the Web

ASP.NET MVC inline functions in a razor view


Here is the syntax for defining inline functions in an ASP.NET MVC razor view. I found this particularly useful when working with Umbraco as the regular alternatives like extension methods and helper classes aren’t available.

    HtmlString PrintSomething()
        return new HtmlString("Hello World");

Returning a HtmlString object will allow you to print to the screen.


Like this article?
Subscribe for more!