为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文件说明问题的一个好工作这里。

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.