我如何可以访问整个查询字符串在ASP.net控制器动作 [英] How can I access the entire query string in an ASP.net controller action

查看:123
本文介绍了我如何可以访问整个查询字符串在ASP.net控制器动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,如果我有这样XController /动作?ID = 1的URL和一个操作方法

I know that if I have an url like XController/Action?id=1, and an action method

void Action(int id)

id参数将自动从查询字符串读取。

the id parameter will automatically be read from the query string.

但我怎么可以访问整个查询字符串时,我事先不知道的所有参数的名称。例如:

But how can I access the entire query string when I don't in advance know the name of all parameters. E.g:

void Action(QueryStringCollection coll) {
    object id = coll["id"];
}

是否有可能做这样的事情?

Is it possible to do something like this?

推荐答案

使用的Request.QueryString

Request.QueryString.Keys 给你所有参数的名称

这篇关于我如何可以访问整个查询字符串在ASP.net控制器动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆