views:

429

answers:

2

i am posting a simple action.

public void Login(FormCollection formCollection)
{
   ...
}

Even with few querystring values, the formcollection.Count is 0. Is it by behaviour?

+3  A: 

FormCollection uses POST values and not what's in the query string. Your action should look:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Login(FormCollection formCollection)
{
   ...
}
Darin Dimitrov
Thanks. I am trying to avoid Request object.
Adeel
how would this be done using http get? I want to keep the values in the url to allow a user to save the results of a search
Chev
@Chev, you use `Request["paramName"]` with GET requests.
Darin Dimitrov
+1  A: 

This is just a comment (I'm not allowed to post comments) to the above question within the comments, "how would this be done using http get"? I realize purists would say you're doing something wrong if you're using the form collection in a get (or maybe if you're using it at), but I simply don't agree; I'm using a get because I'm getting a FileResult, I'm not binding to my model object (for various reasons), and I can't separate my form fields into params because it includes a multi-select list. Thus, I'm just loading the collection myself:

var realCollection = new FormCollection( Request.QueryString );
dudeNumber4