hepler 方法的最佳位置是 MasterPage 还是 App_Code?
在 MasterPage 中放置辅助方法是一个好习惯吗?
我是否应该担心,当我在 App_Code 文件夹中引入新类时,可能会导致在内存中创建更多对象,并且构建和应用程序启动时间也会增加?
谢谢!
Is it a good practice to place helper methods within the MasterPage?
Should I be worried that when I introduce new classes in App_Code folder it can result more objects to be created in the memory and build and application start times will be increased as well?
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的辅助函数特定于您的 MasterPage 模板的页面类型,那么请继续并将其放入其中。否则,将其添加到 App_Code。
不必担心将函数或几个类放入 App_Code 所需的内存。这并不重要。
If your helper function is specific to the type of page that your MasterPage templates, then go ahead and put in in there. Otherwise, add it to the App_Code.
Don't worry about the memory required to put a function or a couple classes in the App_Code. It's not significant.
我认为如果它们与 MasterPage 无关,最好将它们放入某个特殊类(例如静态类)中,否则某些基类可以作为解决方案。您可以拥有多个母版页...
I think it's better to put them into some special class (e.g. static one) if they are not related to the MasterPage otherwise some base class can be the solution. You can have more than one MasterPage...