且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 ASP.NET Core 从查询字符串中读取值?

更新时间:2023-02-17 09:21:03

您可以使用 [FromQuery] 将特定模型绑定到查询字符串:

You can use [FromQuery] to bind a particular model to the querystring:

https://docs.microsoft.com/en-us/aspnet/core/mvc/models/model-binding

例如

[HttpGet()]
public IActionResult Get([FromQuery(Name = "page")] string page)
{...}