title: Passing a large HTML string from View to Controller
body: <p><strong>Note:</strong> I'm a front-end developer wearing a .Net developer's hat for now. Laughable, I know, but how I ended up in this mess is not the point of this question. With that disclaimer out of the way, here's what is happening.</p>
  
  <p>As the title suggests, I need to pass a quite long HTML string (as in multiple pages of text) from a View to a Controller. I spent the last few days researching various ways to achieve this. TBH, some things made sense while some didn't.</p>
  
  <p>Here's my code piece inside <strong>View</strong>:</p>
  
  <pre><code>var html =
      "&lt;form id='htmlContent' action='" + customUrl + "' method='post'&gt;" +
          "&lt;input type='hidden' name='content' id='contentStr'&gt;" +
      "&lt;/form&gt;";
  
  // string literal html gets appended to some element...
  
  $("#htmlContent").submit();
  </code></pre>
  
  <p>A few things I'd like to point out here:</p>
  
  <ul>
  <li>I'm using a string literal to construct the form here because this DOM needs to be dynamically attached to other element at some point.</li>
  <li>Whether I'm using a valid HTML string is out of the question. I've already tested its validity separately and everything looks fine.</li>
  <li>I'm intentionally using jQuery's <code>submit()</code> method instead of using <code>Ajax</code> call.</li>
  </ul>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>[HttpPost]
  public ActionResult ParseHtml(FormCollection form)
  {
      string htmlStr = form["content"].ToString();
      ....
      // some code in between, but the first line appears to be causing an error or
      // the value is not being retrieved.
      ....
      return new EmptyResult();
  }
  </code></pre>
  
  <p>I understand I'm working within the context of MVC framework and I sort of comprehend the concept of it. But, knowing how to implement it with my very limited knowledge is another thing (especially when you inherited a bad code base from someone who's long gone from your project!) </p>
  
  <p>I'd like to think this is quite straightforward and easy to do, but I've been spinning my wheels for much longer than I'd like to. Any pointers to the right direction will be much appreciated.</p>