0

I'm trying to create a form in episerver, it's just an ASP.NET MVC site. The piece of code I'm using is this

@using (Html.BeginForm("Index", "Search", new { language = ContentLanguage.PreferredCulture.Name }, FormMethod.Get))
{
   ...
}

When the page is rendered, I get:

<form action="/site-search/Index?language=en" method="get">...</form>

however, I need the "en" language component to be put at the start of the URL like so:

"/en/site-search/Index"

The reason it is needed there is because the site uses multiple languages and this is how it checks to see which version of the page to serve.

Anyone have any ideas on how to move the "/en/" component to the front of the url using the Html.BeginForm() method?

uneatenbreakfast
  • 545
  • 6
  • 15
  • You need to create a custom route - `url: "{language}/{controller}/{action}` –  Nov 03 '16 at 22:43
  • Probably this one may solve your issue: https://github.com/jondjones/EpiServerCustomFormWithRouting. AFAIK, the language attribute will create `
    ` instead of custom action routing.
    – Tetsuya Yamamoto Nov 04 '16 at 02:21

0 Answers0