Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 07, 2013 11:41 PM by rstrahl
Dec 28, 2012 09:26 PM|LINK
I need to create a setting configuration in my project so user can be able to update the language from my application (not directly from resx file). But the problem is, when i try to create a routine to update resx file at runtime, after that modification
the application rescycled and the session is gone.
Is it possible to update resx file at runtime without restart the session/application?
Many thanks :)
Dec 28, 2012 09:41 PM|LINK
The resx is compiled into an assembly and an update to assemblies in ~/bin trigger an app domain recycle. So, in short, you don't want to do it this way.
Can you explain in more detail what you're trying to do?
Dec 29, 2012 08:23 AM|LINK
thanks for the answer. My goal is to implement multilingual web application and give the admin the ability to maintain the language through the portal. In order to do that, I need to be able to change resx file at the runtime, because all the language stored
on the resx file. Or do you have maybe another idea in order to accomplish my goal?
Dec 29, 2012 01:38 PM|LINK
So you want the translation to be performed at runtime by an admin type person? Or you already have all the translations done and you just want to show the different languages?
Dec 29, 2012 02:22 PM|LINK
Dec 29, 2012 02:24 PM|LINK
So in that case, I'd say that the .resx approach isn't the right approach. Keep your translated values in a database and render them dynamically. Then the admin can change them via your admin tool.
Dec 29, 2012 09:54 PM|LINK
Is there any example to create multilanguage website using database?
Because I still don't have idea to render the translated value into webform. Thanks
Dec 29, 2012 11:36 PM|LINK
I don't know of any, but you'd basically need to query the DB for each page request for all the translatable strings that need to be displayed.
Jan 07, 2013 11:41 PM|LINK
There are a number of ways this can be accomplished and yes you can even update resx files at runtime, although that's probably not such a good idea.
1) Update Resx Files in App_GlobalResources, App_LocalResources
If you use localization based on 'classic' localization using these folders for resources, it's possible to dynamically update these resx files dynamically at runtime. As others have mentioned these folders are monitored by ASP.NET and if there's a change
the application is recylced which can be expensive in terms of performance, but it works.
The real problem here is that if you make many changes there's a big performance impact on the site, but also if there's any sort of input error or XML encoding error in the .resx files ASP.NET will fail compilation and totally lock up your site.
2) Use a custom ASP.NET Resource Provider
ASP.NET supports creation of custom resource providers that can serve resources from alternate sources. Personally I think that if you need to modify resources dynamically at runtime a database is a better way to do this as it allows you to share the data
among developers. It's also easier to update the localization data without forcing a restart of the app for every single change made.
Some years ago I posted an article on how to create a database driven resource provider along with a sample and online editor.
The article can be found here:
A sample can be found here:
(click on the little icons to jump to the resource edit form)
Hope this helps,
+++ Rick ---