2

I have the following controller:

class FooController : Controller
{
  public ActionResult SomeAction(id)
  {
     Type t = Type.GetType(id);
     object o = Activator.CreateInstance(t);
     ((MyModel)o).ParseParamaters(PostParameters); // I need to pass the post parameters here
     //...
  }
}

I would like to fetch all the POST parameters that were submitted.
How can it be done?

2 Answers 2

2

You do that with

[HttpPost]
public ActionResult SomeAction(id, FormCollection form)
{
    //do what you want with the collection
}
Sign up to request clarification or add additional context in comments.

2 Comments

The HttpPost attribute cannot be found. This is for MVC 2. I am using 1.1
I changed the attribute to AcceptVerbs(HttpVerbs.Post)] and it worked. Thanks.
1

I believe Request.Querystring is just a collection of strings, so you could pass it as a parameter to ParseParameters. Or you could just pass the whole Request object.

But I'm wondering why you'd want to, when there's perfectly good model binding built into MVC to do all the heavy lifting for you. http://weblogs.asp.net/nmarun/archive/2010/02/25/asp-net-mvc-model-binding.aspx

1 Comment

Because I can't tell which type is being created.

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.