CesarGon CesarGon - 1 month ago 10
ASP.NET (C#) Question

Global resources for additional cultures being ignored on ASP.NET web app

I have this ASP.NET web application that I am developing with Visual Studio 2015 and .NET 4.6.1. I make extensive use of local and global resources to localize my app into English (default), Spanish and Galician. On my development machine, which uses IIS Express, everything works fine. But when I publish the web app to our production server, which uses IIS 7 on Windows Server 2008, the Spanish global resources are ignored, and only the default English as well as Galician are used.

I am publishing the web app through the "file system" method of Web Publish. As far as I can see, no

.resx
files get deployed for global resources; instead, files named
App_GlobalResources.resources.dll
get deployed into the
bin
,
bin/es
and
bin/gl
folders. In addition, a
MyNamespace.resources.dll
file is deployed to
bin/es
but not
bin/gl
, which is very odd.

I must also say that I am switching cultures in my code by setting
Thread.CurrentThread.CurrentUICulture
to a
CultureInfo
object based on either
en-GB
,
es-ES
or
gl-ES
.

I have tried naming the global resource files in my code by using neutral (for example,
gl
) and localised (for example,
gl-ES
) forms of the culture codes. This does not seem to make any difference. Also, local resource files are named by using neutral variants.

Any ideas why the Spanish global resources are being ignored? Thanks.

Answer

Naming the resource files correctly should work e.g. Have you tried naming the files using the full culture specification e.g. ResourceTexts.resx, ResourceTexts.es-ES.resx and ResourceTexts.gl-ES.resx. After publishing, they should be available in the App_GlobalResources folder.