HttpContext.GetGlobalResourceObject Always null from class library

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 press F5, everything will be fine. If I deploy to a web server, all calls to GetGlobalResourceObject will return as null.

Resources exist. How to get them?

Thank,

Richard

+3
source share
2 answers

I have a problem too, and yes "GetGlobalResourceObject (...)" always returns null after posting.

, , 'GetGlobalResourceObject ( "Captions", "button_go_text" )' 'Resources.Captions.ResourceManager.GetString(key)'


    public static string GetResMsg(this HtmlHelper htmlHelper, string key)
    {
      try
      {
        return Resources.[resource class name].ResourceManager.GetString(key);
      }
      catch
      {
        return "?";
      }
    }

, ,

+5

, GlobalResourceProxyGenerator

-

Resource file properties

, HttpContext.GetGlobalResourceObject, null.

0

All Articles