9

This is my first question here!

I have one ASP.NET MVC 3 Project with a Properties folder, containing some .resx files used to difference content in my views by language (en/es). I'm working in VS2010 with .Net 4.

When I deploy the application to server, I find that no resx files are published, and instead of it, I have some .dll files.

I have set the build action to Embedded resource , Do not copy to output directory and PublicResXFileCodeGenerator as Custom Tool in .resx files properties.

I want to have .resx files on the server and be able to edit them without recompile or redeploy. The views should use those changes.

How can I do that?

Thanks for your help!!

scott-pascoe
  • 1,463
  • 1
  • 13
  • 31
Jawen
  • 1,416
  • 1
  • 14
  • 26
  • 1
    I had resx files into Properties folder. Maybe using them from App_GlobalResources folder will let me do that? – Jawen Jul 23 '12 at 15:15
  • 1
    I tried that solution and works! – Jawen Jul 23 '12 at 16:45
  • PublicResXFileCodeGenerator seems to be a wrapper for http://msdn.microsoft.com/en-us/library/system.resources.tools.stronglytypedresourcebuilder.aspx which converts resx to classes (dlls). Is it necessary for what you're doing? – Alex Ghiculescu Oct 12 '12 at 07:21
  • Before I found the solution I've tried PublicResXFileCodeGenerator, but it wasn't what I was looking for. Thanks! – Jawen Jan 15 '13 at 15:17

1 Answers1

5

Put the resx files in your App_GlobalResources and change the "Build Action" to Content and "Copy To Output Directory" to false. Make sure the "Custom Tool" is set to GlobalResourceProxyGenerator

That should make them changeable even at runtime.

You can simply use xpath to query over them, take the keys, values and comments and edit them as you wish using an XDocument.

You should also know that such a thing won't work with visual studio's publish because App_GlobalResources is not allowed with precompiled website.

Adam Tal
  • 5,911
  • 4
  • 29
  • 49
  • Thanks Adam. When I found that solution I tried and worked fine! – Jawen May 24 '13 at 17:15
  • @Adam Tal, I have follwoed above steps, it is worlking but all sessions are cleared/ app pool is recycled after editing string resource at runtime. How did you maintained that? – Pawan Aug 20 '14 at 08:41
  • @Pawan - The application pool will recycle once it detects any change in App_GlobalResources - you shouldn't edit the resx a lot! If you have such a need you might consider a database based solution – Adam Tal Sep 17 '14 at 12:33
  • @AdamTal, Thanks for suggestion. I have chosen database based solution. :) – Pawan Sep 22 '14 at 04:51