Asp.Net MVC @helper template in different folder than App_Code [duplicate]

不羁岁月 提交于 2019-12-24 00:59:52

问题


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.


回答1:


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)


来源:https://stackoverflow.com/questions/11689333/asp-net-mvc-helper-template-in-different-folder-than-app-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!