@helper directive and App_Code folder were removed in ASP.NET 5.

It was used mostly to abstract piece of Razor code with few parameters. For example:

@helper Row(string label, object value, string format = "{0}")
    var text = string.Format(format, value);

And (in my case) there are about 10 pages (reports) with about 50 helpers as small nice building blocks (as in example above, though they might be a bit bigger). And they are really easy to write and to use and to change parameters etc.

(Also each view has its own helpers so I don't really care about App_Code folder and don't know how it might be a reason to remove @helper directive)

So I'm really interested what to use now as proper alternative to @helper with coming ASP.NET 5 and Razor 4...

I saw two suggestions:

  • tag helpers
  • view components

Well, creating about 500 tiny classes and corresponding templates and passing parameters through properties doesn't sound right at all. Also using tag helpers without templates requires sticking string manually together.

Any suggestions?

Related posts

Recent Viewed