Problem with localized MvcSiteMapProvider on IIS

Oct 5, 2010 at 4:17 PM

Hi,

I use the MVCSiteMapProvider in an MVC2 project with localization.

It works fine when I run the application in Visual Studio but as soon as I deploy it on IIS 6, I get an error message that the Resources-object can't be found.

The error occurs when I use this statement.

<%= Html.MvcSiteMap().SiteMapPath()%>

Then I get this exception

System.InvalidOperationException: The resource object with classname 'Resources' and key 'SiteMasterHelpTitle' was not found.

Here's the specific part of my Web.sitemap

<mvcSiteMapNode title="$Resources:Resources, SiteMasterHelpTitle" controller="Help" action="Index">
            <mvcSiteMapNode title="$Resources:Resources, HelpEditTitle" controller="Help" action="Edit" />
            <mvcSiteMapNode title="$Resources:Resources, HelpCreateTitle" controller="Help" action="Create" />
        </mvcSiteMapNode>

My resource files are in "App_GlobalResources" (e. g. App_GlobalResources/Resources.resx)

Is anything wrong with this configuration or does anyone have a solution for the problem?

Cheers,

Helmut

Coordinator
Oct 6, 2010 at 1:22 PM

Can you try adding <%$Resources: Resources, HelpCreateTitle%> in a literal control somewhere and check if that works (without sitemap)?

Oct 6, 2010 at 1:30 PM

Hi,

I think I know what's the problem.

It doesn't have anything to do with MvcSitemapProvider but with the traditional Sitemap implementation and the deployment to IIS6 with Visual Studio's publish feature.

In this thread someone has a similar problem

http://www.eggheadcafe.com/software/aspnet/29073497/global-resources-not-localized-on-iis.aspx

When using the publish feature of Visual Studio (only copy the necessary files) it generates a ./App_GlobalResources folder on the root.

Here I find files like
Resources.es-ES.resx, Resources.it-IT.resx, ...

The base file Resources.resx isn't there but could be found in ./bin/App_GlobalResources

If I copy this file manually into ./App_GlobalResources the Sitemap localization works.

But this is only a workaround. I wonder what goes wrong here...

 

Coordinator
Oct 6, 2010 at 2:25 PM

Glad you found it, strange behaviour indeed.

Oct 6, 2010 at 2:41 PM

So, here is the real solution (for those that might have the same issue):

I recreated all resources from scratch and gave them the name "PortalResources.resx"in folder "App_GlobalResources".

In the new Resources the namespace for the designer.cs-File is "namespace Resources"

My old Resource file was named "Resources.resx" and lived in the namespace "TPortal.App_GlobalResources" (the project's named TPortal). I don't know were this namespace came from, as the new namespace is just "Resources".

But nevertheless, I did these two changes (renaming and different namespace) and now it works fine.

Maarten, thanks for the support.

 

Cheers,

Helmut