views:

634

answers:

2

Hi all, What are the best usage of the following resource files.

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

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

Thanks,
Soe Moe

A: 

Properties -> Resources can be seen outside of your views and strong types are generated when you compile your application.

App_* is compiled by ASP.NET, when your views are compiled. They're only available in the view. See this page for global vs. local.

Craig Stuntz
+2  A: 

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. Scott Allen blogged about this a while ago. He does a good job of explaining the problem with App_GlobalResources in ASP.NET MVC.

http://odetocode.com/Blogs/scott/archive/2009/07/16/resource-files-and-asp-net-mvc-projects.aspx

Ryan Rivest
Heh. Just wanted to post exactly the same. Works like a charm. :)
Arnis L.