Try our conversational search powered by Generative AI!

Getting localized url in forms

Vote:
 

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?

#113468
Nov 21, 2014 10:50
Vote:
 

Hi,

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 })
#113476
Nov 21, 2014 11:44
Vote:
 

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 :(

#113477
Nov 21, 2014 11:48
Vote:
 

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. site.dk => da-DK, site.se => sv-SE

#113478
Nov 21, 2014 11:52
Vote:
 

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

#113494
Nov 21, 2014 15:10
Vote:
 

This was fixed in Episerver Update 47

#115276
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.