should formcollection be empty on asp.net mvc GET request

十年热恋 提交于 2019-12-06 20:05:56

问题


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?


回答1:


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

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


来源:https://stackoverflow.com/questions/2265194/should-formcollection-be-empty-on-asp-net-mvc-get-request

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