routing and url in addressbar (multiple arrays

Topics: Customizing Orchard
Mar 31, 2014 at 4:07 PM
Hey everyone,

I have a custom controller to generate a list of listboxes to do some filtering, now I would like that when a user submits the lists of arrays are shown in the addressbar. How can I do this?

This is my route:
                new RouteDescriptor {
                    Priority = 5,
                    Route = new Route(
                        new RouteValueDictionary {
                            {"area", "Assortiment"},
                            {"controller", "Assortiment"},
                            {"action", "Index"},
                            {"*postedTerms", UrlParameter.Optional}
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "Assortiment"}
                        new MvcRouteHandler())
This is my view:
@model List<taxTermViewModel>
                    @using (Html.BeginFormAntiForgeryPost(Url.Action("Index", "Assortiment", FormMethod.Post)))
                for (var i = 0; i < Model.Count; i++) 

                    //Array.CreateInstance(typeof(string), 0);
                    @Html.HiddenFor(x => x[i].PostedTerms.TermIds);
                    <div class="checkboxList">
                                                  x => x[i].PostedTerms.TermIds,
                                                  x => x[i].AvailableTerms,
                                                  term => term.Id,
                                                  term => term.Name,
                                                  x => x[i].SelectedTerms,

            <input class="green" type="submit" 
                      value="POST to Controller" />
This is how my controller accepts the posted Id's:
        public ActionResult Index(List<taxTermViewModel> postedTerms)
            return View(GetTermsModel(postedTerms));
Mar 31, 2014 at 10:26 PM
POST wont change the address bar, POST insert's the data in to the body of the Request.....

You want the URL to change? Or do you just want the ViewModel to be populated?
Marked as answer by borrierulez on 4/2/2014 at 2:19 AM
Apr 1, 2014 at 7:29 AM
Edited Apr 1, 2014 at 9:57 AM

The viewmodel is already populated but I also want the url to change so the user can copy past his selection (the url) and send it to someone. Also if he clicks the back button after selecting something that he comes back to his selection and doesn't loose anything.

Like here:

On the left you can select some filters, you click on a laptop to see the detail and if you click the back button you are taking back to your filterpage with the filters intact.

Also fyi, this is what is posted back if i for instance select on of the checkboxes:

So I would like to put that in a quertstring but i don't have a clue how

Apr 2, 2014 at 9:19 AM

I found it, seems that it has to be a get + my beginformanti.. wasn't setup correctly, it needs to be like this:

@using (Html.BeginFormAntiForgeryPost(Url.Action("Index", "Assortiment"), FormMethod.Get))

That works! Thanks for helping me
Marked as answer by borrierulez on 4/2/2014 at 2:19 AM