加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-3 – 我可以在App_Code之外使用全局剃须刀@helper吗

发布时间:2020-12-16 00:39:34 所属栏目:asp.Net 来源:网络整理
导读:问题很简单,如标题所示:有没有办法在“App_Code”之外使用剃刀助手? 示例(HtmlEx.cshtml文件): @helper Script(string fileName,UrlHelper url){script src="@url.Content("~/Scripts/" + fileName)" type="text/javascript"/script } 我问这个是因为我
问题很简单,如标题所示:有没有办法在“App_Code”之外使用剃刀助手?

示例(HtmlEx.cshtml文件):

@helper Script(string fileName,UrlHelper url)
{
<script src="@url.Content("~/Scripts/" + fileName)" type="text/javascript"></script> 
}

我问这个是因为我没有什么别的可以放入App_Code;我想结构我的项目有点不一样。

谢谢。

更新:我不想要任何其他类型的扩展。斯科特在这里谈论的只有纯粹的剃刀助手,我才有兴趣:http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx

解决方法

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

不,没有。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读