How to create custom extensions in mvc

Custom Extension in ASP.NET MVC
1. Create a folder named Utilities inside project folder.
2. Create your extension class as static class.

namespace AlobinProject.Utilities
     public static class Utilities
        public static string HelloWorld(this HtmlHelper html)
           return "Hello World";

3. Create a static method inside the extension class.
4. Declare the namespace in the view as,
@using AlobinProject.Utilities
5. Use the extension method as

Leave a Reply