[英]Redirect to action with querystring array
我正在嘗試使用查詢字符串數組重定向到操作:
string[] variantIds = new {
"test1",
"test2",
};
return RedirectToAction("SamplesOrderStep3", new { variantIds });
但這重定向到
sample-order-step3?variantIds=System.String%5B%5D
我如何將它送到 go 到
sample-order-step3?variantIds=test1&variantIds=test2
看起來您無法直接使用重定向到操作進行重定向 - 最后我使用了混合或Url.Action
和Redirect
:
return Redirect($"{Url.Action("SamplesOrderStep3")}?variantIds={string.Join("&variantIds=", variantIds)}");
我相信這個“你如何鏈接到一個將數組作為參數的動作(RedirectToAction 和/或 ActionLink)?” 描述了你的情況, Lee Smith的回答似乎相似且有用。
我認為最好將其轉換為帶有分隔符的字符串
string variantIdsString = "test1,test2";
或者嘗試使用字符串列表而不是數組。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.