Asp.net global resource error 'Resource object with key' 'not found'

I use the asp.net global resource to try and implement a bilingual website. I added a simple resource to the en-Us.resx global resource file, which contains:

Password | Text Email | Text 

then executed it in the text box on the default page:

 <asp:TextBox runat="server" ID="loginEmail" Text="<%$ Resources:en-US, Email %>" ></asp:TextBox> 

but when I run the page on localhost , I get this error:

Resource object with key not found

I am using asp.net 4.0, what is the problem?

+6
source share
2 answers

Resource file format - ResourceName.culture.resx

Create a resource file in the App_GlobalResources folder called Main.resx. This is for the default culture (i.e. invariant)

Then create a resource file Main.en-US.resx

All resources for culture in the USA will live here, etc.

 Main.resx Main.en.resx Main.en-US-resx Main.en-AU.resx Main.fr.resx Main.fr-FR.resx 

and etc.

To access this from a web page, use the syntax

 <%$ Resources:Main, Email %> 

Do not worry about the culture, the system will work. It will exactly match the first (en-US), and then work with these cultures parent (en), the parent parent (Invariant).

Change the name "Main" to suit your needs.

+13
source
  • Change the file name to en-US.aspx.resx and try again. See it helps.
  • Try changing the assembly actions and see what happens. See here
-1
source

Source: https://habr.com/ru/post/910032/


All Articles