2

Like I said in the title of my question, is it possible to put the @helper template of cshtml file in a folder other than App_Code to be visible by my views?

I discovered the very nice article from ScottGu but I don't found any solution to my question.

Thank you.

Samuel
  • 12,073
  • 5
  • 49
  • 71

1 Answers1

2

You can, if you write them as extension methods (static methods of a static class). Something like:

public static string AMethod(this HtmlHelper html, int arg)
...

Lets you call the method in a cshtml file as

@Html.AMethod(5)
  • sorry, but I want razor helpers and not any other kind of extensions (HtmlHelper and such)... please check this: http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx – Samuel Jul 27 '12 at 14:44