mardi 4 août 2015

Default text from .resx file disappearing from website in C#

I have a project involving a template website, that has a set of default text strings stored in a resx file, Resource.resx

I recently came across the idea of using an English language resx file, Resource.en.resx, to store text specific to each instance of the customized website. This way I can have certain pieces of text (such as addresses or other contact information) stored, while being able to easily change text for all instances of the template website. It is similar to Are resx files a suitable way to customise for different customers? except that each instance of the website has its own environment, so there is no confusion on which "version" of the text should be loaded.

However, I have been encountering a problem where the text on the page is disappearing, with the exception of the text from the Resource.en.resx file. No errors are being thrown, the areas where the text appears are just appearing as blank. This can be fixed temporarily by doing an iis reset on the website's server, but I have not been able to determine how or why this is happening.

I believe that it is a caching issue, that somehow the resx is loading "blank" values for the "missing" values in the Resource.en.resx file, even though my understanding of resx files is that any missing key should default to the text from the default file. I have a theory that the text disappears sometimes after an iis reset (which is also a method for making it reappear).

I am using C# with .Net 4.5. I am not currently changing the website's culture directly, though that is something I will be adding in the future. My methodology works most of the time, but I need to know if there is a solution to this intermittent problem, or if I will need to find another method for more easily loading text.

Has anyone encountered this before, or have any idea why it might be happening?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire