Can I have a global razor @helper outside of App_Code?

前端 未结 4 1648
轻奢々
轻奢々 2021-01-01 14:39

The question is simple as stated in the title: Is there a way of having razor helpers outside of \'App_Code\'?

Example ( HtmlEx.cshtml file ):

@hel         


        
4条回答
  •  被撕碎了的回忆
    2021-01-01 15:10

    Use the Razor Generator extension on a view with helpers inside and you'll generate the code for the view before compilation time. The generated view code is part of your project and compiles into the assembly, so you can place the view file anywhere and use the helpers anywhere, even from a unit test.

提交回复
热议问题