title: Passing dynamic data to controller with ASP.NET MVC and jQuery on form submit
body: <p>I have a website which is basically a single page containing a bunch of dynamic content. In normal operation the user should never leave this page. To handle/report certain errors though, I need to redirect to an error page. So on the error page I want to provide a link back to the normal page which provides the app the information required to rebuild all the dynamic content which was previously open.</p>
  
  <p>I think I can rebuild the page by parsing the querystring with javascript and reloading dynamic content. I'm not sure if this is the best way, but I've got it working. So href in the link on my error page needs to look something like:</p>
  
  <pre><code>MySite/MyController/MyAction?1,5,8,9
  </code></pre>
  
  <p>where the numbers in the querystring basically indicate the Id's of content sections to load in on <code>document.ready</code>.</p>
  
  <p>I'm now stuck on how to generate this link though. I think I need to pass these numbers into the controller somehow, so the controller can pass them into the error view which will then generate the "back" link.</p>
  
  <p>I have a standard html form for uploading a file:</p>
  
  <pre><code>using (Html.BeginForm("MyAction", "MyController", 
                         FormMethod.Post, 
                         new { enctype = "multipart/form-data" }))
  
                         { /* ... */ }
  </code></pre>
  
  <p>I then have a button which calls the jQuery <code>.submit()</code> method on the form.</p>
  
  <p>So, the question, when I click on the button which submits the form, how can I attach the additional data so I can access it in my controller?</p>
  
  <p>Hope that's clear, if not let me know and I can provide more detail. Thanks. </p>
  
  <p><strong>Edit</strong>: It occured to me that I could submit this information with a hidden field in the form. I'll try that if I can't find a better way, but I'd like a more generic solution if possible as I have a number of forms on the page and ideally I'd like this data available to any/all of them.</p>