通过urlparams将数组发送到控制器动作

发布于 2025-01-23 05:17:13 字数 681 浏览 3 评论 0原文

我有一个AffairesController的Action Reportssrs

public async Task<IActionResult> ReportSsrs(
    int affaireId, 
    int[] coucheIds = null, 
    int[] secteurIds = null)
{
    return ...
}

我想发送一个事件ID和两个IDS Couchesecteur

我尝试使用以下URL,

//localhost:5001/affaires/reportssrs?affaireId=9&coucheIds[]=10&secteurIds[]=23

但是当我放置断点并击中操作时得到的是什么,似乎并不是很好,阵列值:

通过URL将数组传递到动作的正确方法是什么?

I have the action ReportSsrs of a AffairesController

public async Task<IActionResult> ReportSsrs(
    int affaireId, 
    int[] coucheIds = null, 
    int[] secteurIds = null)
{
    return ...
}

I want to send an affair id and two arrays of ids couche and secteur

I try to use the following URL

//localhost:5001/affaires/reportssrs?affaireId=9&coucheIds[]=10§eurIds[]=23

however what I get when I put a breakpoint and the action is hit, it does not seem to pass very well, the array value:
enter image description here

What is the correct way to pass an array via the URL to the action?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耀眼的星火 2025-01-30 05:17:13

正确的URL应该是:

localhost:5001/affaires/reportssrs?affaireId=9&coucheIds=10§eurIds=10

如果您的数组包含多个项目,则URL应该是:

[...]/reportssrs?affaireId=9&coucheIds=10&coucheIds=11§eurIds=10§eurIds=12

The correct url should be:

localhost:5001/affaires/reportssrs?affaireId=9&coucheIds=10§eurIds=10

If your array contains more than one item, the url should be:

[...]/reportssrs?affaireId=9&coucheIds=10&coucheIds=11§eurIds=10§eurIds=12
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文