How to extract key/values from FormCollection in ASP.NET MVC?

To avoid you from having to chase for the same information: here’s how you extract key / value pairs from the FormCollection that comes as an argument in an ASP.NET MVC action method:

Also, a final tip: If you find that the formCollection does not contain the key/value pairs you expected, check that

  • Your controls reside within the correct form (you can have more than one)
  • Your controls have names (just having an id is not returning values in the formCollection)Hope this helps.

Siddharth Pandey

Siddharth Pandey is a Software Engineer with thorough hands-on commercial experience & exposure to building enterprise applications using Agile methodologies. Siddharth specializes in building, managing on-premise, cloud based real-time standard, single page web applications (SPAs). He has successfully delivered applications in health-care, finance, insurance, e-commerce sectors for major brands in the UK. Other than programming, he also has experience of managing teams, trainer, actively contributing to the IT community by sharing his knowledge using Stack Overflow, personal website & video tutorials.

You may also like...

Advertisment ad adsense adlogger