0

I'm trying to build URL in razor view that will pass 2 RouteData.Values to my action. This is my code in view:

    <a href="@Url.RouteUrl("CompleteFrameBrand", new { groupId = group.Id, groups = Model.Groups })"><img src="@("../../Themes/Pac/Content/images/" + group.Id + ".png")" style="vertical-align: middle; max-height: 120px; max-width: 340px;" alt="logo"/></a> 

This is code in controller:

    public ActionResult CompleteFrameBrand(string groupId, List<PacNopGroup> groups)

and this is my route provider:

    routes.MapLocalizedRoute("CompleteFrameBrand",
            "pacmodule/completeglass/{groupId}",
            new { controller = "PacCompleteFrame", action = "CompleteFrameBrand" },
            new[] { "Nop.Web.Controllers" });

In view I have 9 Items in Model.Groups. But when I pass it to new controller it counts 0. Even if I pass hwole model I get null in controller. Can someone explain me how should I correctly pass model object from view to controller through Url.RouteUrl. Thank you.

Korl
  • 95
  • 3
  • 15
  • possible duplicate of [Multi-value GET parameters - route generation](http://stackoverflow.com/questions/21605430/multi-value-get-parameters-route-generation) – Dave Bish Apr 14 '14 at 17:02
  • it is not duplication. if i have both param as string i get it corectly to the controller. but if one is object with list inside this list become empty in controller. don't know why :( – Korl Apr 15 '14 at 09:30
  • yeah - because the route generation is wrong - see the solution in the answer I posted – Dave Bish Apr 15 '14 at 11:20
  • You seem to be passing a collection of complex types on the querystring. Have you thought about using TempData, or persisting to cookie / session instead? – Antony Koch Apr 15 '14 at 11:28

0 Answers0