在我的 mvc3 Web 项目中,我有一个 App_GlobalResources 文件夹,其中包含资源文件 Permissions.resx。
当我在 Visual Studio 中本地运行站点时,我能够访问此文件中的值:
string value = (string)HttpContext.GetGlobalResourceObject(resourceClass, key);
但是,一旦我将其部署到生产 Web 服务器,它就无法访问此文件中的值。我检查过,它正在包含该文件的发布目录的 bin 文件夹中创建 App_GlobalResources 。
我第一次使用全局资源文件,部署到网络服务器后是否需要执行任何其他步骤才能使其正常工作?
谢谢。
In my mvc3 web project I have an App_GlobalResources folder containing the resource file Permissions.resx.
I am able to access the values in this file when I run the site locally in visual studio using:
string value = (string)HttpContext.GetGlobalResourceObject(resourceClass, key);
However, once I deploy it to the production web server it is not able to access the values in this file. I checked and it is creating App_GlobalResources in the bin folder of the publish directory containing the file.
My first time using global resource files, is there any additional steps required to get this working once deployed to the webserver?
Thanks.
发布评论
评论(1)
我很确定 App_GlobalResources 不应该在 bin 文件夹中创建。您是否设置了
复制到输出文件夹
? (你不应该需要它)。在 WebForms 中,在 .resx 文件的属性中,我们将
Build Action
设置为Content
,并将Custom Tool
设置为GlobalResourceProxyGenerator
代码>.这会为 bin 文件夹中的资源创建 dll。但是,我没有在 MVC 中使用 App_GlobalResources(这使得在 Web 上下文之外进行测试变得很棘手),但这里有一些可能有用的信息:
http://odetocode.com/Blogs/scott/archive/2009/07/16/resource-files-and-asp-net-mvc-projects.aspx
I'm pretty sure App_GlobalResources should not be created in the bin folder. Have you got
Copy to output folder
set? (You shouldn't need it).In WebForms, in properties of the .resx files, we have
Build Action
set toContent
andCustom Tool
set toGlobalResourceProxyGenerator
. This creates dlls for the resources in the bin folder.However, I've not used App_GlobalResources in MVC (it makes things tricky to test outside of a web context), but there's some info here that might be useful:
http://odetocode.com/Blogs/scott/archive/2009/07/16/resource-files-and-asp-net-mvc-projects.aspx