无需重新编译即可在部署服务器中编辑 ASP.NET MVC 3 resx 文件 [英] Edit ASP.NET MVC 3 resx files in deployment server without recompiling

查看:19
本文介绍了无需重新编译即可在部署服务器中编辑 ASP.NET MVC 3 resx 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在这里的第一个问题!

This is my first question here!

我有一个带有 Properties 文件夹的 ASP.NET MVC 3 项目,其中包含一些 .resx 文件,用于按语言 (en/es) 在我的视图中区分内容.我在 VS2010 中使用 .Net 4.

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.

当我将应用程序部署到服务器时,我发现没有发布任何 resx 文件,而是有一些 .dll 文件.

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

我已将构建操作设置为 Embedded resourceDo not copy 到输出目录和 PublicResXFileCodeGenerator 作为 .resx 文件属性中的自定义工具.

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

我希望在服务器上有 .resx 文件并且能够在不重新编译或重新部署的情况下编辑它们.视图应使用这些更改.

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.

我该怎么做?

感谢您的帮助!!

推荐答案

将 resx 文件放入您的 App_GlobalResources 并将构建操作"更改为 内容 和复制到输出目录"为假.确保自定义工具"设置为 GlobalResourceProxyGenerator

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.

您可以简单地使用 xpath 查询它们,获取键、值和注释,然后使用 XDocument 随意编辑它们.

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

您还应该知道,这样的事情不适用于 Visual Studio 的发布,因为 App_GlobalResources 不允许用于预编译网站.

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.

这篇关于无需重新编译即可在部署服务器中编辑 ASP.NET MVC 3 resx 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆