我想在视图中调用控制器中的一个动作,并且必须向控制器发送一系列值,但是该动作调用了控制器但发送了空值。请帮助我
查看代码:
var _getDocumentsUrl = '@Html.Raw(@Url.Action("GetDocuments", "Document", new { Section = "0", Province = "1", County = "0", District = "0", area = "Province" }))';
控制器中的操作:
public IActionResult GetDocuments(AreaVM area)
{///codes////}
型号:
public class AreaVM
{
public string? Section { get; set; }
public string? Province { get; set; }
public string? County { get; set; }
public string? District { get; set; }
}
将section = 0、Province = 1、County = 0、District = 0的值发送给控制器
您必须指定应从查询的哪一部分构建对象。 Url.Action 将参数传递给 uri,所以您可能需要它([FromUri] 添加):
public IActionResult GetDocuments([FromUri]AreaVM area)