How to fetch resource value from .resx file stored in my own custom folder location?
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 开发者_JS百科loop dynamically.
GetLocalResourceObject doesn't seem to work as it only seems to look for the resource file in a specific location.
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.
You can extend the ResourceManager like the StringsResourceManager used in the article .NET String Resources.
精彩评论