How to use app_GlobalResource or app_LocalResource?

Afshar Mohebi picture Afshar Mohebi · Jul 7, 2010 · Viewed 38.4k times · Source

How to use them in a ASP.NET Web Application project? Any difference?

many thanks

Answer

Pranay Rana picture Pranay Rana · Jul 7, 2010

Local Resources:

  1. Local resource is specific to a single Web page and used for providing versions of a Web page in different languages.
  2. Local resources must be stored in App_LocalResources sub folder.
  3. Local resources must be named in format [.language / language and culture].resx.

Ex: Default.aspx.resx- Base resource file. This is the default, or fallback, resource file.

Default.aspx.de.resx- A resource file for German etc.

Global Resources:

Global Resources Localization Suggestion for ASP.NET

  1. Global resource can be read from any page or code that is in the application.
  2. Global resource must be stored in App_GlobalResources at the root of the application.

    // Get the global resource string. 
    
     try
     { 
         globalresourcestring = (String)GetGlobalResourceObject("MyResource", "GlobalResourceString1"); 
     } 
     catch
     { 
         globalresourcestring = "Could not find global resource."; 
     }