title: Passing parameter using action link in MVC
body: <p>I have two views category and product I retrieve products by passing category Id and I want to  implement search function in my products view. when I try to pass category id and search string<br>
  in my controller method search form submit not working if I pass search string alone then its working. how to pass both parameter in controller method. or should I use partial view for this</p>
  
  <p>Category view:</p>
  
  <pre><code>@foreach (var item in Model) 
  {
      &lt;li&gt;
          @Html.ActionLink(
              @item.Category, 
              "Products", "
              Home", 
              new { cid = @item.CategoryId, search = UrlParameter.Optional}, 
              null)
      &lt;/li&gt;
  }
  </code></pre>
  
  <p>Product view:</p>
  
  <pre><code>@using(Html.BeginForm("Products", "Home", FormMethod.Get))
  {
      &lt;b&gt;Search:&lt;/b&gt; @Html.TextBox("search")&lt;input type="submit" value="search" /&gt;
  }
  </code></pre>
  
  <p>Controller method:</p>
  
  <pre><code>public ActionResult Products( string search,int cid) 
  {
      if (!string.IsNullOrEmpty(search))
      {
          var ser = db.searchPro(search);
          return View(ser);
      }
      else
      {
          var Pro = db.getProducts(cid);
          return View(Pro);
      }
  }
  </code></pre>