0

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)?

e.g. Both these list of values should be handled by the method below

  1. 1,A,A
  2. 1,B,A,A

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Create(int id)
    {
    //for each variable in POST store in DB
    }

1 Answer 1

1

You can access the Request.Form collection.

foreach (string field in Request.Form) {
    string name = field;
    string value = Request.Form[field];
    //...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.