Try our conversational search powered by Generative AI!

Getting localized url in forms


We have a multi-language site with one language available per host url. But we can't seem to get the post url correctly localized in our forms, using Html.BeginForm. It's always producing a url from the default language. I can make it work if I explicitly set the url using UrlResolver, but shouldn't this work out of the box just by passing actionName and controller?

Nov 21, 2014 10:50


Have you tried passing on routevalues in your Html.BeginForm? An example would be

Html.BeginForm("Action", null, new { node = yourcontentlink, language = yourlanguagecode })

Html.BeginForm("Action", "Controller", new { language = yourlanguagecode })
Nov 21, 2014 11:44

It works if I specify route values explicitly but my thought was that this should work out of the box? The form is in a standard view (no partial). If I have to explicitly set language in all cases then there's a lot of rework to be done :(

Nov 21, 2014 11:48

I get the exact same behavior for Url.Action... it never respects the language. Is this something in the configuration I've missed?

FYI, we have a 1:1 mapping between host url and language, so we never have language explicitly in the url, i.e. => da-DK, => sv-SE

Nov 21, 2014 11:52

After some investigation this has been confirmed by Episerver to be a bug in the 7.5 routing, and has been reported here: Bug #119805: Language is resolved wrongly when using e.g. @Html.BeginForm or @Html.ActionLink

Nov 21, 2014 15:10

This was fixed in Episerver Update 47

Jan 13, 2015 2:54
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.