System argument exception mvc .net
<p>I am passing the parameters in query string. When I hover the link in the browser it shows correctly the key-value pairs in query string. When I click the link, firstly, the breakpoint is not fired at the particular action and, secondly, I got the following exception:</p>

<blockquote>
  <p>The parameters dictionary contains a null entry for parameter
  'endDate' of non-nullable type 'System.DateTime' for method
  'System.Web.Mvc.ActionResult GetAllExpenses(System.String,
  System.String, System.DateTime, System.DateTime)' in
  'GPI.Controllers.HomeController'. An optional parameter must be a
  reference type, a nullable type, or be declared as an optional
  parameter.</p>
</blockquote>

<p>I understand it is asking for <code>endDate</code> parameter to not be null, but value is being passed in variable of query string. I didn't get it. Please help me to  understand this.</p>

<p>Initially I tried this:-</p>

<pre><code>/Home/GetAllExpenses?userId=@ViewBag.Id&amp;expType=debit&amp;startDate=@quarterThreeStartDate&amp;endDate=@quarterThreeEndDate
</code></pre>

<p>and have the same problem</p>

<p>after that I tried this:-</p>

<pre><code>/Home/GetAllExpenses?userId=@HttpUtility.UrlEncode(ViewBag.Id)&amp;expType=debit&amp;startDate=@HttpUtility.UrlEncode(quarterThreeStartDate)&amp;endDate=@HttpUtility.UrlEncode(quarterThreeEndDate)
</code></pre>

<p>Again I get the same exception.</p>

<p>This is the image of link in browser. You can see that all values of variables are there</p>

<p><a href="https://i.stack.imgur.com/EvEbv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EvEbv.jpg" alt="enter image description here"></a></p>

<p>the link in the image corresponds to 1st box i.e quarter 1 and debits</p>

<p>I have these following variables in my partial view which I passed to their respective links in querystring:</p>

<pre><code>var quarterOneStartDate = new DateTime(ViewBag.Year, 1, 1);
    var quarterTwoStartDate = new DateTime(ViewBag.Year, 4, 1);
    var quarterThreeStartDate = new DateTime(ViewBag.Year, 7, 1);
    var quarterFourStartDate = new DateTime(ViewBag.Year, 10, 1);

    var quarterOneEndDate = new DateTime(ViewBag.Year, 3, 31);
    var quarterTwoEndDate = new DateTime(ViewBag.Year, 6, 30);
    var quarterThreeEndDate = new DateTime(ViewBag.Year, 9, 30);
    var quarterFourEndDate = new DateTime(ViewBag.Year, 12, 31);
</code></pre>