我知道如果我有一个像 XController/Action?id=1 这样的 url 和一个 action 方法
void Action(int id)
id 参数将自动从查询字符串中读取。
但是当我事先不知道所有参数的名称时,如何访问整个查询字符串。例如:
void Action(QueryStringCollection coll) {
object id = coll["id"];
}
有可能做这样的事情吗?
最佳答案
使用 Request.QueryString 为了这
Request.QueryString.Keys 给你所有参数的名称
关于asp.net-mvc - 如何在 ASP.net Controller 操作中访问整个查询字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/998389/