Reading a String From a Resources File in Asp.Net at RunTime

Posted by Matheus Guimaraes |02 Feb 16 |


ok, at present, this information is as difficult to find on the web at the moment as it is stupidly simple.

if you google you most likely are going to come across solutions that new up a ResourceManager class based on a full namespace and an assembly name and most likely you may have run into problems.

If you all you are trying to do is load something from your statically defined Resources file in ASP.Net, all you need to do is use the static ResourceManager property like so:

var resourceManager = ResourceFileName.ResourceManager;
var text = resourceManager.GetString(“keyintheresourcefile”);

You can also get any other objects allowed in a Resources file besides strings such as files or images; you just have to call the right method on the ResourceManager object.