简体   繁体   中英

HttpContext.GetLocalResourceObject Method not returning required resources

On switching Language from UI I am expecting resource in respective language but I am always getting English resource as shown below. I am trying to access local resources in my "inplant-printing-dashboard.ashx" as below,

public static string GetLocalResource(string resourceKey)
{
string Status = HttpContext.GetLocalResourceObject
("~/resource/handlers/inplant/
inplant-printing-dashboard.ashx",
resourceKey,    
System.Globalization.CultureInfo.CreateSpecificCulture
(Convert.ToString(HttpContext.Current.Session["lang"])))
 as string;
    return Status;
}





I have resource files 
-inplant-printing-dashboard.it.ashx.resx( 'it' for Italian)
-inplant-printing-dashboard.ashx.resx (default for English)
-[![enter image description here][1]][1]
-

I am supposed to get resource in Italian when I change language to Italian but I don't understand why HttpContext.GetLocalResourceObject(...) returns resource in English always.

I think the format of your resx filenames may be incorrect. The language code should come after the pagename, and before the resx extension, like so:

inplant-printing-dashboard.ashx. it .resx

inplant-printing-dashboard.ashx. fr .resx

See here for more details https://msdn.microsoft.com/en-us/library/fw69ke6f.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM