Why is StringValues used for Request.Query values?

后端 未结 4 1493
粉色の甜心
粉色の甜心 2020-12-25 10:08

Let\'s say I have some url that looks like this: www.myhost.com/mypage?color=blue

In Asp.Net Core, I\'d expect to get the color query parameter value by doing the fo

4条回答
  •  我在风中等你
    2020-12-25 10:24

    Request.Query["color"] returns StringValues because collection of string values can be passed. So, I would suggest you to handle this as action parameter, model binding.

    public ActionResult SaveColor([FromUri] string[] color);
    

提交回复
热议问题