I’m starting to develop an application using ASP.NET MVC 4 framework with Razor syntax. I want to know where (folder location) I should create my HTML Helper class. Best practice.
For example:
- VisualStudioSolution
- Controlles
- Html
- HtmlHelperClass.vb
- Models
- Views
use this.To use the “@helper” feature in Razor you need to place the CSHTML file in the App_Code folder of your app. There is no “Views/Helpers” folder in ASP.NET MVC 3. ScottGu’s blog post was written before the feature was fully implemented, and some of the notes there are not entirely accurate anymore.
To call the “@helper” that you wrote you have to include both the filename as well as the name of the helper inside it. For example, if you have this helper:
And this content:
Then you call it like so: