编辑资源文件而不重新编译 ASP.NET 应用程序
我想使资源文件在部署后可以编辑。 我读了 这篇帖子表明这是可能的,但我似乎无法弄清楚需要更改哪些设置才能启用此功能。
我已将 App_GlobalResources 文件夹添加到我的 ASP.NET 3.5“Web 应用程序”中,并向该文件夹添加了一个资源文件。 我假设需要更改此文件的构建操作,但无论我将构建操作更改为什么,我都无法实现上述功能。
将App_GlobalResources文件夹和资源文件复制到bin目录中。 部署后,对 .resx 文件的任何编辑都不会显示。
有任何想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以做到这一点,而我刚刚做到了。
选择项目中的资源文件。 将构建操作更改为内容。 确保“复制到输出目录”设置已关闭。 部署项目时,App_GlobalResources 目录和 .resx 文件将被复制到网站的根目录。 您可以修改 .resx 文件,您的实时站点将识别这些更改。
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.
Web 应用程序项目与网站项目不同。 我怀疑您能否通过 Web 应用程序项目实现您想要的目标。 您可以查看这篇文章:
ASP.NET 网站或 ASP.NET Web 应用程序?
资源通常是静态的。 它们是程序使用的图像、字符串和文件等项目,并且可以依赖它们的存在(因此在字符串/RESX 文件的情况下可以是强类型的)。 使用资源的原因只是将它们与 DLL 捆绑在一起,以便分发和引用资源变得更加容易。
在运行时可编辑表明您可能想要使用项目或用户设置,或者可能是数据库? 如果您需要使用 RESX 文件,您可能需要编写代码来读/写它们。
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.