title: MVC Is there a way to make sure a specific ViewModel property doesn't get passed in a Html.BeginForm(action, controller, ModelData)?
body: <p><strong>ANSWERED</strong></p>
  <p><em>See answers section below</em></p>
  <p>I've been struggling for hours with this problem and I haven't found anything that relates, so apologies if this post is a duplicate.</p>
  <p>I'll start by constructing a problem related to my own.</p>
  <p>Let's say we create a ViewModel:</p>
  <pre><code>public class XmlViewModel(){
  
      [Required]
      public string Code { get; set; }
  
      public string XML { get; set; }
  }
  </code></pre>
  <p>and a constructor method which loads the View and as well as another that gets called when the submit is registered on the View.</p>
  <pre><code>public class Extractor{
  
  public ActionResult Index()
  {
      XmlViewModel xmlVM = new XmlViewModel ()
      {
          XML = &quot;Sample XML&quot;;  
      };
  
      return View(xmlVM);
  }
  
  public ActionResult GetXml(XmlViewModel xmlVM){
  
      
      xmlVM.XML = GetXMLByCode();
  
      return View (&quot;Index&quot;, xmlVM)
      
  }
  }
  </code></pre>
  <p>Then the view <strong>Index</strong> as below</p>
  <pre><code>
  @model Project.ViewModel.XmlViewModel
  
  @{
      ViewBag.Title = &quot;Index&quot;;
  }
  
  @using (Html.BeginForm(&quot;GetXml&quot;, &quot;Extractor&quot;, Model))
  {
      @Html.AntiForgeryToken()
  
      &lt;div class=&quot;form-horizontal&quot;&gt;
          &lt;hr /&gt;
          @Html.ValidationSummary(true, &quot;&quot;, new { @class = &quot;text-danger&quot; })
  
          &lt;div class=&quot;form-group&quot;&gt;
              @Html.LabelFor(model =&gt; model.Code, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
              &lt;div class=&quot;col-md-10&quot;&gt;
                  @Html.EditorFor(model =&gt; model.Code, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
                  @Html.ValidationMessageFor(model =&gt; model.Code, &quot;&quot;, new { @class = &quot;text-danger&quot; })
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;form-group&quot;&gt;
              @Html.LabelFor(model =&gt; model.XML, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
              &lt;div class=&quot;col-md-9&quot;&gt;
                  &lt;pre id=&quot;XML&quot;&gt;@Html.Raw(Html.Encode(Model.XML))&lt;/pre&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;form-group&quot;&gt;
              &lt;div class=&quot;col-md-offset-2 col-md-10&quot;&gt;
                  &lt;input type=&quot;submit&quot; value=&quot;Generate XML&quot; class=&quot;btn btn-default&quot;/&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
      &lt;/div&gt;
  }
  </code></pre>
  <p>So in this scenario I'm starting the page with:</p>
  <p><a href="https://i.stack.imgur.com/ctCC5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ctCC5.png" alt="enter image description here" /></a></p>
  <p>When the user clicks Submit using a XML Code, I want the Code to be run against some collection of XML, then that returned XML replaces the &quot;SampleXML&quot;</p>
  <p>Problem is when the form gets submitted again(Twice) (Now with the XML field holding a few hundred characters) it overloads the Query and returns this:</p>
  <p><a href="https://i.stack.imgur.com/cNgSZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cNgSZ.png" alt="enter image description here" /></a></p>
  <p>Because yep you guessed it, the XML fills up the Request with the XML from the previous Form result.</p>
  <p>So my question is, is there any way to clear the ViewModel Property so it isn't passed in the Query, or some attribute to add that will tell the ViewModel to not pass the property through the Html.BeginForm()?</p>
  <p>If possible I would like to stay away from passing the ViewModel properties individually as the actual problem's ViewModel is more complicated and it would be troublesome going down that route.</p>