为Asp.net MVC资源文件的最佳实践 [英] Best Practice for Asp.net MVC Resource Files

查看:286
本文介绍了为Asp.net MVC资源文件的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是下面的资源文件的最佳使用。

What are the best usage of the following resource files.


  1. 属性 - >资源(菲尔的利用这一资源在DataAnnotation本地化)

  2. App_GlobalResources文件夹

  3. 文件夹App_LocalResources文件

  1. Properties -> Resources (Phil used this resource for localization in DataAnnotation)
  2. App_GlobalResources folder
  3. App_LocalResources folder

我也想知道什么是(1)和(2)在asp.net MVC应用程序之间的差异。

I also would like to know what is the difference between (1) and (2) in asp.net mvc application.

谢谢,结果
梭萌

Thanks,
Soe Moe

推荐答案

您应该避免 App_GlobalResources文件 App_LocalResources文件
像克雷格提到,有与 App_GlobalResources文件 / App_LocalResources文件的问题,因为你不能在ASP.NET外访问它们运行。如何这将是问题的一个很好的例子就是当你单元测试你的应用程序。

You should avoid App_GlobalResources and App_LocalResources. Like Craig mentioned, there are problems with App_GlobalResources/App_LocalResources because you can't access them outside of the ASP.NET runtime. A good example of how this would be problematic is when you're unit testing your app.

K。斯科特·艾伦的博客上讲述这个前一阵子。他确实在ASP.NET MVC与 App_GlobalResources文件说明问题的一个好工作<一个href=\"http://odeto$c$c.com/Blogs/scott/archive/2009/07/16/resource-files-and-asp-net-mvc-projects.aspx\"相对=nofollow>这里。

K. Scott Allen blogged about this a while ago. He does a good job of explaining the problem with App_GlobalResources in ASP.NET MVC here.

这篇关于为Asp.net MVC资源文件的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆