Sharing Resource Files in a Mixed (Webforms / MVC) Application

878 Views Asked by At

I have One application which has Webforms (.aspx) pages and also MVC3, both. I intend to keep labels, message text and other text in a .resx file. Many of the keys/values in .resx file are common across both webforms and MVC.

I would prefer not to have to maintain 2 resource files containing the same resources -- one file in App_GlobalResources (for webforms) and another .resx file somewhere else in another folder, for MVC.

Is there any way to share/access One Resource file between webforms pages and MVC code? (at present I have 2 files, and it is a pain to ensure they are in sync).

Thanks!

1

There are 1 best solutions below

0
On

You can do this by adding an existing item as link feature http://msdn.microsoft.com/en-us/library/9f4t9t92%28v=vs.80%29.aspx.

  1. Create a resource file resource.resx in your solution folder
  2. Create App_GlobalResources folders inside your MVC/Web forms projects
  3. Open context menu and select add existing item (From the Open button drop-down list, select Add As Link) to add the shared resource file to your projects