ASP.NET MVC - Pass array object as a route value within Html.ActionLink(…)

前端 未结 6 2117
别跟我提以往
别跟我提以往 2020-12-01 23:13

I have a method that returns an array (string[]) and I\'m trying to pass this array of strings into an Action Link so that it will create a query string similar to:

6条回答
  •  执笔经年
    2020-12-01 23:59

    There is a library called Unbinder, which you can use to insert complex objects into routes/urls.

    It works like this:

    using Unbound;
    
    Unbinder u = new Unbinder();
    string url = Url.RouteUrl("routeName", new RouteValueDictionary(u.Unbind(YourComplexObject)));
    

提交回复
热议问题