Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 877
erikkallen Avatar asked Jun 15 '09 21:06

erikkallen


1 Answers

Use Request.QueryString for this

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

like image 55
eu-ge-ne Avatar answered Nov 10 '22 01:11

eu-ge-ne