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

前端 未结 6 2116
别跟我提以往
别跟我提以往 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:50

    Another solution that just came to my mind:

    string url = "/Controller/Action?iVal=5&str=" + string.Join("&str=", strArray); 
    

    This is dirty and you should test it before using it, but it should work nevertheless. Hope this helps.

提交回复
热议问题