Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for ASP.NET MVC resource files

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.

like image 293
Soe Moe Avatar asked Dec 09 '09 17:12

Soe Moe


People also ask

What is a resources RESX file?

resx resource file format consists of XML entries, which specify objects and strings inside XML tags. It contains a standard set of header information, which describes the format of the resource entries and specifies the versioning information for the XML used to parse the data.


1 Answers

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 here.

like image 74
Ryan Rivest Avatar answered Nov 10 '22 02:11

Ryan Rivest