0
votes

I want to get a resource value from my .resx file that is NOT stored in the local resource folder.

How can I do this?

I am currently using the strongly typed file that is generated, but in this case I can't use the strongly typed as I am building the key (which is a string) in a loop dynamically.

GetLocalResourceObject doesn't seem to work as it only seems to look for the resource file in a specific location.

2

2 Answers

0
votes

You can pass a path to when using GetLocalResourceObject. Bare in mind you may hit problems if the external source is not get compiled.

 HttpContext.GetLocalResourceObject("~/Views/SomeView/Index.cshtml", "Prop");

This expects a resx file at the following location.

 ~/Views/SomeView/App_LocalResources/Index.cshtml.resx

You can also precompile resx resources and create a custom provider to locate them.

0
votes

You can extend the ResourceManager like the StringsResourceManager used in the article .NET String Resources.