title: BeginForm changing the "Name" value
body: <p>Before I ask my question let me state that I DID look online, and I DID look on stack overflow for this question and DID find certain solutions but none of what I found worked for me. So I am asking here to hopefully get an answer to this question and appreciate any help given. </p>
  
  <p>I am doing a Form post to an external website. In my model I created all the values by doing the following in my LoginViewModel:</p>
  
  <pre><code>public string returnurl { get; set; }
  </code></pre>
  
  <p>In my constructor i set the values needed like so:</p>
  
  <pre><code>returnurl = "www.retururl.com";
  </code></pre>
  
  <p>In my index page I to the post like so using Razor in MVC 4.0:</p>
  
  <pre><code>@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "myForm", @action = Model.loginUrl }))
  {
     @Html.HiddenFor(model =&gt; model.returnurl)
  }
  </code></pre>
  
  <p>When I check on fiddler it does the following behind the scenes:</p>
  
  <pre><code>&lt;input id="returnurl" name="returnurl" type="hidden" value="www.returnurl.com"&gt;
  </code></pre>
  
  <p>It makes the input id AND name the name of the variable returnurl. </p>
  
  <p>My problem is that one of the name values in my form post MUST be "bb-post". I obviously can not name a variable bb-post in my loginViewModel so what I tried was just setting the name to something like bb_post then in my index page.</p>
  
  <p><strong>So i did the following:</strong></p>
  
  <pre><code>@Html.HiddenFor(model =&gt; model.bb_post, new { name = "bb-post" })
  </code></pre>
  
  <p>but this did not work, when i checked fiddler it did the following:</p>
  
  <pre><code>&lt;input id="bb_post" name="bb_post" type="hidden" value="" /&gt;
  </code></pre>
  
  <p><strong>I also tried this:</strong></p>
  
  <pre><code>@Html.HiddenFor(model =&gt; model.bb_post, new { @name = "bb-post" })
  </code></pre>
  
  <p>but got this:</p>
  
  <pre><code>&lt;input id="bb_post" name="bb_post" type="hidden" value="" /&gt;
  </code></pre>
  
  <p><strong>And finally tried this:</strong></p>
  
  <pre><code>@Html.HiddenFor(model =&gt; model.bb_post, new { @Name = "bb-post" })
  </code></pre>
  
  <p>but got this:</p>
  
  <pre><code>&lt;input Name="bb-post" id="bb_post" name="bb_post" Name="bb-post"  type="hidden" value="" /&gt;
  </code></pre>
  
  <p>Using the capital name as so @Name gives me two name values. This is not what I am looking for. </p>
  
  <p>I DO realize that I can just write it this way directly in to the html:</p>
  
  <pre><code>&lt;input id="bb_post" name="bb-post" type="hidden" value="" /&gt;
  </code></pre>
  
  <p>But in order to keep it all the looking the same I was hoping there was a way to keep this format:</p>
  
  <pre><code>@Html.HiddenFor(model =&gt; model.bb_post, new { @Name = "bb-post" })
  </code></pre>
  
  <p>Thank you.</p>
  
  <p><strong>Edit:</strong>
  I did find the answer in the Question that was recommended but the accepted answer was not correct. I must have not looked further than the accepted answer by mistake (I usually do and apologize). But the following is what worked if someone else accidentally skips the answer to this for going by the accepted answer which is WRONG because it generates TWO name values. 
  This was the correct answerd and what worked for me:</p>
  
  <pre><code> @Html.Hidden("bb-post", Model.bb_post, new { id="bb-post" })
  </code></pre>
  
  <p>Thanks.</p>