Question

I have page with culture chooser control. This control is rendered as a partial on the Layout page.

@Html.Partial("~/Views/Shared/CultureChooserUserControl.cshtml")

The culture chooser control looks like this:

@Html.ActionLink("English", "ChangeCulture", "Default",  new { lang = "en", returnUrl =     this.Request.RawUrl }, new { @class = "englishFlagButton" })
@Html.ActionLink("Deutsch", "ChangeCulture", "Default",  new { lang = "de", returnUrl = this.Request.RawUrl }, new { @class = "germanFlagButton" })
@Html.ActionLink("French", "ChangeCulture", "Default",  new { lang = "fr", returnUrl = this.Request.RawUrl }, new { @class = "frenchFlagButton" })
@Html.ActionLink("Italian", "ChangeCulture", "Default",  new { lang = "it", returnUrl = this.Request.RawUrl }, new { @class = "italianFlagButton" })

The culture change method is in the default controller of the page, which gives the following when I want to change the culture:

http://localhost/myapp/Default/ChangeCulture......

Now i seperated my site with areas, the problem is that when I try to change the culture when I am in an area the request is wrong and that leads to an error:

http://localhost/myapp/**AREA/Default**/ChangeCulture.....

How can I fix this. Thanks for your support in advance.

Frank.

Was it helpful?

Solution

When your layout use all areas and culture change action is in controller in default area then set in layout in your routeValues object area = "" in all helpers that address to this action, for example:

@Html.ActionLink("English", "ChangeCulture", "Default",  new { lang = "en", returnUrl = this.Request.RawUrl, @area = "" }, new { @class = "englishFlagButton" })
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top