C# AspNetCore中的属性绑定
我正在使用:C# AspNetCore中的属性绑定,c#,dictionary,asp.net-core,C#,Dictionary,Asp.net Core,我正在使用: return RedirectToAction("GetSchedule", new { requirements = preCheckParams.Requirements, weightValues = preCheckParams.WeightValues}); 在我的aspnetcore应用程序中。接下来,我想在另一个操作中重用传递给匿名对象的值: public IActionResult GetSchedule(List<string> requireme
return RedirectToAction("GetSchedule", new { requirements = preCheckParams.Requirements, weightValues = preCheckParams.WeightValues});
在我的aspnetcore应用程序中。接下来,我想在另一个操作中重用传递给匿名对象的值:
public IActionResult GetSchedule(List<string> requirements, Dictionary<string, int> weightValues)
public IActionResult GetSchedule(列出要求、字典权重值)
奇怪的是,第一个值被绑定到GetSchedule操作中的列表,而第二个对象(字典)是空的。在这种情况下,是否有关于词典的特殊规则?您不能在RedirectToAction的routeValues参数中传递类 RedirectToAction方法返回值是HTTP 302(Status302Found),它生成对指定操作的GET请求。这意味着您的所有参数都将作为查询字符串放入URL中 可以在URL中传递字符串列表/数组
要求
,因为它绑定到查询字符串中的?要求=value1&requirements=value2&
等,但任何比这更复杂的内容都不能绑定,只能绑定基元值
我首先想到的有几个选择:
如果我的回答对你有帮助,请将其标记为已回答