title: How to map query string to model data ASP.Net MVC
body: <p>i heard from a write up that we can pass query string with <code>Html.BeginForm()</code> so i did this way</p>
  
  <pre><code>@using (Html.BeginForm("Index", "Home", FormMethod.Post, new { CustomerName = "joydev" }))
  </code></pre>
  
  <p>but when i post the form then it was not mapped to my model data.</p>
  
  <h2>here is my viewmodel</h2>
  
  <pre><code>public class MyViewModel
  {
      public string CustomerName { get; set; }
      public List&lt;Movies&gt; movies { get; set; }
      public List&lt;Hobbies&gt; hobbies { get; set; }
  }
  </code></pre>
  
  <p>see my action</p>
  
  <pre><code>[HttpPost]
  public ActionResult Index(MyViewModel oVm, string CustomerName)
  {
       ViewBag.Message = "Success";
       return View(oVm);
  }
  </code></pre>
  
  <p>i saw string CustomerName was empty and <code>oVm CustomerName</code> was null. just tell me where i made the mistake for which <code>CustomerName</code> is not passing as query string to action method. please guide me. thanks</p>
  
  <h2>Edit</h2>
  
  <p>Some one said :- data is posted as query string. In action it is available through all three methods i.e. In Model, Action Parameter and through Request.QueryString.</p>
  
  <pre><code>public ActionResult Login(LoginModel model, string returnUrl, string testparam)
          {
  
              string additionalParamValueFromQueryString = Request.QueryString["testparam"]; // Method 1
              string additionalParamValueFromModel = model.testparam; // Method 2
              string additionalParamValue = testparam; // Method 3
  }
  </code></pre>
  
  <p>see the url <a href="http://forums.asp.net/p/2070398/5975252.aspx?p=True&amp;t=635801707044672469" rel="nofollow">http://forums.asp.net/p/2070398/5975252.aspx?p=True&amp;t=635801707044672469</a></p>