27

I'd like to enable the resource files to be editable after deployment. I read this post which suggests that this is possible, but I can't seem to figure out what settings I need to change to enable this.

I have added the App_GlobalResources folder to my ASP.NET 3.5 "Web Application" and added a resource file to this folder. I assume that the Build Action for this file needs to be changed, but no matter what I change the Build Action to, I cannot achieve the above stated functionality.

The App_GlobalResources folder and the resource file are copied into the bin directory. Once deployed, any edits to the .resx file are not being displayed.

Any ideas?

Community
  • 1
  • 1
deckerdev
  • 2,766
  • 2
  • 21
  • 23

2 Answers2

28

You can achieve this, and I just did it.

Select the resource file in your project. Change the Build Action to content. Make sure that the Copy to Output Directory setting is turned OFF. When you deploy your project, the App_GlobalResources directory and your .resx file will get copied to the root of your web site. You can modify the .resx file and your live site will recognize the changes.

Mike Cole
  • 14,474
  • 28
  • 114
  • 194
  • 12
    If you do this your application pool will recycle on your web ap – Dan Oct 07 '09 at 20:38
  • What are the negative repercussions of that happening? – Mike Cole Oct 08 '09 at 14:36
  • 2
    Simply put, all current sessions will end. – Ant Swift Jun 27 '11 at 14:46
  • recycling in my app that does not rely on `Session` is not a problem. So this solution save my day. – Afshar Mohebi Jul 13 '13 at 13:41
  • 1
    I get this error - Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "" was correctly embedded or linked into assembly "" at compile time, or that all the satellite assemblies required are loadable and fully signed. Is it because of the website/webapplication stuff? Mine is a web application. – Moiz Tankiwala Dec 19 '13 at 11:54
  • 1
    @Mike, I followed the steps in your answer, but this does seem to work for me. I am on ASP.Net 4.5 and I have an ASP.Net web forms application that has a UI screen to edit the resource file live. – Moiz Tankiwala Dec 19 '13 at 12:27
  • 2
    This will recompile application which means all current sessions will be lost. Not valid solution. – Altaf Patel Oct 25 '14 at 15:40
  • Not only will sessions be lost but you are incurring massive overhead on the first hit to your site after the recycle. Would not recommend this approach. – womp Oct 01 '15 at 16:19
  • what is I have kept OutProc session to SQL? – kaushalparik27 Oct 05 '15 at 10:53
  • 8
    @AltafPatel If you change a web.config your app pool will recycle too, does that mean everyone who wants to use appsettings to keep from having to redeploy their applications is doing it wrong? – moarboilerplate Oct 15 '15 at 19:30
  • @moarboilerplate Didn't get what exactly you meant to say. – Altaf Patel Oct 16 '15 at 07:20
  • 7
    @AltafPatel - I think he means, by your logic you can never use web.config settings either, because: "Changing a web.config setting will recycle your app pool which means all current sessions will be lost. Not a valid solution." The idea of this answer is that even though you have to recycle the app pool after a change, it's MUCH better than having to recompile and redeploy the code, which also would recycle the app pool. – TTT Feb 16 '16 at 17:55
  • 2
    I don't believe this solution actually works. I followed instructions exactly - the modified resource does not get used unless I rebuild and redeploy my project DLL's. – Ciaran Gallagher Oct 10 '17 at 08:13
  • how to edit .resx file in asp.net core application without recompiling? it's build action is set to Embedded Resource and Copy to output directory is set to Copy always, but after deployment if i change in .resx it is not getting reflected. is there any way to do so? i also tried to set build action to Content but it gives error while running application after deployment – Madhav Sep 07 '18 at 09:08
13

A Web Application project is different than a Web Site project. I doubt you can achieve what you want with a Web Application project. You might check out this post:

ASP.NET Web Site or ASP.NET Web Application?

Resources are generally meant to be static. They are items such as images, strings, and files that your program consumes and can rely on being present, (and therefore can be strongly typed in the case of strings/RESX files). The reason for using resources is simply to bundle them in with your DLL's so that distribution and referencing the resources becomes much easier.

Editable at runtime suggests you might want to use project or user Settings, or maybe a database? If you need to use RESX files you might need to write code to read/write them.

Community
  • 1
  • 1
womp
  • 115,835
  • 26
  • 236
  • 269