title: Using Url.actions with optional parameters
body: <p>Just wondering if anyone can help me. </p>
  
  <p>I have an MVC project and in my view I'm using url.action to link to my action. My action can handle 3 optional parameters Category, SubCategory and a Name. But the problem is SubCategory could be Null so I need Name to replace Subcategory in the URL.Action link. I have my code working but I'm wondering if there is a better way of writing this code. </p>
  
  <p>My URL.Action:</p>
  
  <pre><code>if(subcategory == null)
  {
      &lt;a href="@Url.Action("Action", "Controller", new { Parameter1 = Category, Parameter2 = subcategory, DataParameter3 = name})"&gt;Products&lt;/a&gt;
  }
  else
      &lt;a href="@Url.Action("Action", "Controller", new { Parameter1 = Category, Parameter2 = name})"&gt;Products&lt;/a&gt;
  </code></pre>
  
  <p>Does any one know a better way of doing this?? </p>