Disclaimer : I'm still a rookie, and I'm maintaining a big project made by someone else with little documentation. So I might be missing something obvious.
Here goes : My web application can be accessed by 2 dns names, "www.website.com" and "www.siteweb.com" one in english and the other in french.
There used to be a bilingual splash page that prompts for the language but since we have 2 urls, I had to eliminate the splash page and automatically redirect to the main page in the language that corresponds to the URL that was used to access it.
Here's is the redirection code located on the defunct splash page (index.vbhtml) :
@Code
If Request.ServerVariables("SERVER_NAME").Contains(ConfigurationManager.AppSettings("SiteDNSnameEN")) Then
Response.Redirect(Url.Action("SetLanguage", Resources.ResourceURL.CONTROLLER_LANGUAGE, New With {.pCulture = "en-CA", .pReturnURL = "/Home"}))
ElseIf Request.ServerVariables("SERVER_NAME").Contains(ConfigurationManager.AppSettings("SiteDNSnameFR")) Then
Response.Redirect(Url.Action("SetLanguage", Resources.ResourceURL.CONTROLLER_LANGUAGE, New With {.pCulture = "fr-CA", .pReturnURL = "/Accueil"}))
End If
@EndCode
When on the French "Home" page, the breadcrumb works fine when I use the language toggle button, which refers to a controller that translates the url and triggers "SetLanguage" which basically sets CurrentCulture and CurrentUICulture and reloads the pReturnURL. Everything gets translated properly and there's no problem.
But if I use the English URL (or fake using it, because in dev it's only localhost), the breadcrumb is displayed , but when I press on the language toggle button, the breadcrumb is not being displayed. My best guess is that MVCSiteMapProvider is still looking for the english ressources because the breadcrumb gets displayed on that one page that happens to have the same path in french or english.
I have played around with globac.asax's routes and with the redirecting, but I only achieve to fix one language and screw the other.
I'm sure there is a just a small fix that have been eluding me for quite a while now. Somewhere along the line, the culture change seems to not get done. I've troubleshooted the Action "SetLanguage" and it always shows the expected culture. That might not be it but I'm thinking MVCSiteMapProvider is not always following for some reason.
Here's the part of Global.asax that I've tinkered with :
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
routes.MapRoute( _
"Splash", _
"", _
New With {.controller = "Root", .action = "Index"} _
)
routes.MapTranslatedRoute( _
"TranslatedRoute", _
"{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = ""}, _
New With {.controller = translationProvider, .action = translationProvider}, _
False _
)
Dim controllerHomeEN = Resources.ResourceURL.ResourceManager.GetString("CONTROLLER_HOME", New CultureInfo(WebHelper.CONST_CURRENT_CULTURE_EN))
Dim actionIndexEN = Resources.ResourceURL.ResourceManager.GetString("ACTION_INDEX", New CultureInfo(WebHelper.CONST_CURRENT_CULTURE_EN))
routes.MapRoute( _
"Default", _
"{controller}/{action}/{id}", _
New With {.controller = controllerHomeEN, .action = actionIndexEN, .id = UrlParameter.Optional} _
)