Search code examples
c#asp.net-mvcformcollection

should formcollection be empty on asp.net mvc GET request


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?


Solution

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

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