简体   繁体   English

Web应用程序App_LocalResources无法正常工作

[英]Web Application App_LocalResources Not Working

I have a number of aspx pages contained in external assemblies which are loaded via a custoer PathProvider, all works fine with the exception of local resources for the pages. 我在外部程序集中包含大量的aspx页面,这些页面是通过custoer PathProvider加载的,除了页面的本地资源外,其他所有页面都工作正常。

So for example, I have a project Paul.Pages, within Paul.Pages there are a number of aspx pages, these are all embedded resources and are loaded view PaulPathProvider. 因此,例如,我有一个项目Paul.Pages,在Paul.Pages中有许多aspx页面,这些都是嵌入式资源,并在视图PaulPathProvider中加载。

I have page welcome.aspx which has a single lable welcomeLable (and I have set the Text property to "Hello World") in Paul.Pages, I have generated local resources for this page and now in Paul.Pages I also have a App_LocalResources folder with welcome.aspx.resx, in the .resx file I have welcomeLabelResource1.Text = "Hello Paul". 我在Paul.Pages中有一个页面welcome.aspx,其中有一个标签welcomeLable(并且我已经将Text属性设置为“ Hello World”),我已经为此页面生成了本地资源,现在在Paul.Pages中我也有一个App_LocalResources .resx文件中包含welcome.aspx.resx的文件夹中,我有welcomeLabelResource1.Text =“ Hello Paul”。

When the page loads I would expect to see "Hello Paul" but actually it displays "Hello World" implying the resource string is not being loaded, I have tried setting the welcome.aspx.resx to Embdedded Resource but it makes not difference. 当页面加载时,我希望看到“ Hello Paul”,但实际上它显示“ Hello World”,暗示资源字符串没有被加载,我尝试将welcome.aspx.resx设置为Embedded Resource,但这没有区别。

Any help is much appreciated, this is driving me nuts. 非常感谢您的帮助,这真让我发疯。

Addiontal Info 附加信息

So the welcome.aspx is contained in an assembly OliveERP.Common and is named welcome.aspx, this has Build Action = Embedded Resource as it is loaded using a custom path provider. 因此,welcome.aspx包含在程序集OliveERP.Common中,并命名为welcome.aspx,因为使用自定义路径提供程序加载了它,所以它具有Build Action = Embedded Resource。 The OliveERP.Common has a App_LocalResources folder containing welcome.aspx.resx the page html is OliveERP.Common有一个App_LocalResources文件夹,其中包含welcome.aspx.resx,页面html是

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="welcome.aspx.cs"     Inherits="OliveERP.Common.welcome" culture="auto" meta:resourcekey="PageResource1"     uiculture="auto" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label runat="server" ID="welcomeLabel" Text="Hello World"     meta:resourcekey="welcomeLabelResource1" />
    </div>
    </form>
</body>
</html>

but page still displays Hello World not Hello Paul 但页面仍显示Hello World而不是Paul

seems the following is your problem 似乎以下是您的问题

in the .resx file I have welcomeLabel.Text = "Hello Paul". 在.resx文件中,我具有welcomeLabel.Text =“ Hello Paul”。

<asp:Label runat="server" ID="welcomeLabel" Text="Hello World"     meta:resourcekey="welcomeLabelResource1" />

When your label's resourcekey is welcomeLabelResource1 then in your resx file you should have a resource string welcomeLabelResource1.Text for the Text property. 当标签的资源键为welcomeLabelResource1时,则在resx文件中,Text属性应具有资源字符串welcomeLabelResource1.Text。

可能您的资源文件为“嵌入式资源”,请尝试使它们成为“内容”文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在App_LocalResources中添加文件夹 - Adding Folders in App_LocalResources asp.net App_LocalResources文件夹 - asp.net App_LocalResources folder 如何从Build Process中删除App_LocalResources - How to remove App_LocalResources from Build Process 如何在文件夹app_localresources中添加许多资源? - how to add many resources in folder app_localresources? 如何使用特定区域性从App_LocalResources文件夹中的resx文件读取? - How to read from a resx file in the App_LocalResources folder using a specific culture? 如何通过读取App_LocalResources文件(.resx)来本地化asp:TextBox的占位符 - How to localized asp:TextBox's placeholder by reading App_LocalResources file (.resx) Assembly.GetExecutingAssembly()。GetManifestResourceNames()是否从App_LocalResources返回资源? - Does Assembly.GetExecutingAssembly().GetManifestResourceNames() return resources from App_LocalResources? Azure应用程序日志记录不适用于我的Web App - Azure Application Logging not working for my Web App 将桌面应用程序转换为Web应用程序 - Convert Desktop App to Web Application SignalR不在网站上工作,但在Web应用程序中工作 - SignalR not working in website but works in web application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM