should formcollection be empty on asp.net mvc GET request

Adeel picture Adeel · Feb 15, 2010 · Viewed 8.1k times · Source

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?

Answer

Darin Dimitrov picture Darin Dimitrov · Feb 15, 2010

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

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Login(FormCollection formCollection)
{
   ...
}