I have a resx file in App_GlobalResources in my web application, called with:
Resources.GetResource("ResourceFileName", "Resource")
The helper method lives in a separate class library to get resource values:
using System.Resources;
using System.Web;
public static class Resources
{
public static string GetResource(string resource, string key)
{
try
{
string resourceValue = (string)HttpContext.GetGlobalResourceObject(resource, key);
return string.IsNullOrEmpty(resourceValue) ? string.Empty : resourceValue;
}
catch (MissingManifestResourceException)
{
return string.Empty;
}
}
}
If I hit F5, everything works fine. If I deploy to a web server, all calls to GetGlobalResourceObject come back as null.
The resources exist. How do I get them out?
Thanks,
Richard
I have same problem too and yes “GetGlobalResourceObject(…)” return always null after publish.
So, I found the solution by using instead of ‘GetGlobalResourceObject(“Captions”,”button_go_text”)’ to ‘Resources.Captions.ResourceManager.GetString(key)’
Sample code is like below
I hope that helps,
best regards