InfoPath Web Form repeating attachment error in SharePoint Server 2010

Recently, I created a custom InfoPath form which worked fine on the preview. After publishing to a SharePoint List, the Web form's attachment control in a repeating section failed with the following error.

"The security Validation for this page is invalid. Click back in your Web Browser, refresh the page and try your operation again"

I made the following changes to fix the error.

  1. In the 14 hive, click on the TEMPLATE -> Layouts folder.
  2. Backup the formserver.aspx file as we will be editing this file.
  3. Edit the formserver.aspx using the notepad.exe.
  4. Under the < body runat="server" id="PageBody"> tag, add the following line of code.

<SharePoint:FormDigest runat="server" />

Retry the InfoPath web form, it should be working now.