My Technology Reference

ASP.Net MVC form post FormCollection contains no key or missing some keys

Posted in Microsoft .Net, Web by DK on July 8, 2010

I recently ran into an issue where FormCollection didn’t have any key.

This happens when you are using

  • html controls (not generated via mvc html helper) and
  • you didn’t assign value to name attribute to one or more controls.

Add name attribute to the html control, as rule of thumb keep value of name attribute same as id attribute. This should solve the issue.

Advertisement
Tagged with: , , ,

One Response

Subscribe to comments with RSS.

  1. Matt said, on May 10, 2011 at 2:06 pm

    Thanks for that!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.