RickStrahl / Westwind.Globalization

Database driven resource localization for .NET applications
544 stars 135 forks source link

Problems with instructions in section: Using the ASP.NET Resource Provider #27

Closed citybear01 closed 9 years ago

citybear01 commented 9 years ago

I have an existing WebForm application that uses meta:xxxxx tags in the HTML. So, I followed the instructions you listed in the section labeled "Using the ASP.NET Resource Provider". Now I am getting an error when I start up the application. Below are pictures of the Error screen that appears when the application starts up and the second is a "listing" of my Web Config file

webconfig file error when switching to support using the asp net resource provider

Web Config file:

web config file

citybear01 commented 9 years ago

I also discovered that when I went to the Designer page within my Visual Studio 2013 tab, I was getting these errors as well:

visual studio designer page error

RickStrahl commented 9 years ago

This library requires .NET 4.5. I think you may be running .NET 4.0 and so the assembly either wasn't added to your project or if it was it's not usable because it's the wrong version.

citybear01 commented 9 years ago

I am using .NET 4.5.1:

project framework page

RickStrahl commented 9 years ago

Oh I see the problem. Old project upgraded from 1.x yes?

The assembly for the resourceProviderFactory is Westwind.Globalization.Web. Change in the configuration setting.

citybear01 commented 9 years ago

This was a brand new project built initially for 4.5.1. So, it was not an old project upgraded. I made those changes to the Web Config file and I get the same error:

Here is the Designer Page within VS 2013:

try 02 designer page

Here is the Source for the Designer Page (HTML):

try02 html version of designer page

Here is the revised WebConfig File:

try02 webconfig file

As you can see I am still getting those errors in the Designer.

==> Note, I am able to bring up the page in FireFox <== ==> But I am NOT getting the Meta tags resolved <==

Here is a sample line from the HTML:

==> /asp:Label <==

Here is a screen of this definition using LocalizationAdmin: For lblAmountResource1, here is the entry:

try02 localizationadmin page

citybear01 commented 9 years ago

It looks like the line that I tried to isolate for you did not come out the way I expected.

If you look at the HTML it is line 11 or this text:

"/asp:Label"

The meta:resourcekey is this:

" meta:resourcekey="lblAmountResource1""

citybear01 commented 9 years ago

Looks like my attempt at posting the actual HTML failed again. So, here is a JPEG for that line:

try02 isolated html

RickStrahl commented 9 years ago

I'm not sure...

Can you try this for a sanity check:

Then open the ResourceTest.aspx page. There are a couple of controls in that page. Do those show up correctly? They do for me.

One thing I see in your install is that the versions are not the latest. There was a bug in the previous release that caused issues with WebForms controls and that was fixed in the latest package. Westwind.Utilities should be V2.64. You can also try updating all the assemblies:

From the Package Manager Console:

Update-Package Westwind.Globalization.Web

I think this will update all the dependencies. If not at the very least update Westwind.Utilities as well - it should be 2.64 on the latest rev.

My guess is for some reason or other your various assembly versions are out of sync causing assembly load errors.

citybear01 commented 9 years ago

OK, did what you asked:

Created a new empty web project:

try 03 new project definition

Here is the NuGet Console stuff:

try 03 nuget console stuff

I then tried ResourceTest.aspx and it worked fine.

Tomorrow, I will add my Master Page, Default Page, and remaining code.

And I will try again!

I will let you know.

One final question. Please keep in mind that I am newbie to Visual Studio and .NET. This is my first project and I was a IBM Mainframer up until April.

If I use a meta:resourcekey tag in the HTML, and I change cultures, do I have to explicitly in the code behind obtain the most current culture value for that resourcekey? I thought that when I am using the meta tag in the HTML, the code would take care of it. Do I have to put something inside the JavaScript as well?

RickStrahl commented 9 years ago

No. meta:resourcekey will pick up the active culture.

You do have to enable culture tracking either in the globalization tag in web.config, or using WebUtils.SetCulture() to force the culture to be switched based on browser locale.

citybear01 commented 9 years ago

How do I use WebUtils.SetCulture? Do I call this in the code behind? If so, can you give an example. If not, then where?

Also, how do I code it in the Web.Config.

Please be kind...this is my first project and need a lot of help here.

RickStrahl commented 9 years ago

https://github.com/RickStrahl/Westwind.Globalization/wiki/Auto-Detecting-and-Setting-ASP.NET-Locale-based-on-Browser-Locale