Having razor @helper in App_code folder using ASP.

2019-04-03 07:42发布

Where can I find tutorials on how exactly get this to work?

I am trying to have @helper in App_code directory of my MVC3 app, so far when I try to use them in other razor pages, they cannot be found.

3条回答
干净又极端
3楼-- · 2019-04-03 08:06

Look at this SO question and associated answer: Razor: Declarative HTML helpers

It does work, though I find that in the end, I usually opt for writing another extension method off of HtmlHelper.

查看更多
在下西门庆
4楼-- · 2019-04-03 08:19

You need to call the helpers as static methods of the page name.

For example, if you have a helper named HelpMe in App_Code/MyHelpers.cshtml, you would write

@MyHelpers.HelpMe(...)
查看更多
登录 后发表回答