I want to use the same post Action method for multiple number of input fields. How can I get hold of all the parameters passed to MVC engine (in addition to the method parameter)?
我想对多个输入字段使用相同的post Action方法。如何获取传递给MVC引擎的所有参数(除了方法参数)?
e.g. Both these list of values should be handled by the method below
例如这两个值列表都应该通过以下方法处理
- 1,A,A
-
1,B,A,A
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(int id)
{
//for each variable in POST store in DB
}[AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(int id){//为DB中的POST存储中的每个变量}
1 个解决方案
#1
You can access the Request.Form
collection.
您可以访问Request.Form集合。
foreach (string field in Request.Form) {
string name = field;
string value = Request.Form[field];
//...
}
#1
You can access the Request.Form
collection.
您可以访问Request.Form集合。
foreach (string field in Request.Form) {
string name = field;
string value = Request.Form[field];
//...
}