How can I access the entire query string in an ASP.net controller action

寵の児 提交于 2019-12-10 14:59:43

问题


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

void Action(int 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?


回答1:


Use Request.QueryString for this

Request.QueryString.Keys gives you the name of all parameters



来源:https://stackoverflow.com/questions/998389/how-can-i-access-the-entire-query-string-in-an-asp-net-controller-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!