title: C#.NET MVC4 - null entry for parameter of non-nullable type for a method
body: <p>Within my c#.net project I am getting this error when I try to get an onClick event to begin. I think I may be missing an important assembly reference but cannot figure out why this error is occurring. The project was working fine up until recently and some modification I have made has caused this problem </p>
  
  <p><strong>Issue</strong></p>
  
  <blockquote>
    <h2>SERVER ERROR IN APPLICATION</h2>
    
    <p>Server Error in '/' Application.</p>
  </blockquote>
  
  <p>The parameters dictionary contains a null entry for parameter 'lat' of non-nullable type 'System.Double' for method 'System.Web.Mvc.ActionResult Index(Double, Double, System.String, System.String, System.String, System.String, System.String)' in 'MyDisplayTracking.Controllers.HomeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
  Parameter name: parameters</p>
  
  <p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p>
  
  <p>Exception Details: System.ArgumentException: The parameters dictionary contains a null entry for parameter 'lat' of non-nullable type 'System.Double' for method 'System.Web.Mvc.ActionResult Index(Double, Double, System.String, System.String, System.String, System.String, System.String)' in 'MyDisplayTracking.Controllers.HomeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
  Parameter name: parameters</p>
  
  <p><strong>Source Error:</strong> </p>
  
  <p>An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</p>
  
  <p><strong>Stack Trace:</strong> </p>
  
  <p>[ArgumentException: The parameters dictionary contains a null entry for parameter 'lat' of non-nullable type 'System.Double' for method 'System.Web.Mvc.ActionResult Index(Double, Double, System.String, System.String, System.String, System.String, System.String)' in 'MyDisplayTracking.Controllers.HomeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
  Parameter name: parameters]
     System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo parameterInfo, IDictionary<code>2 parameters, MethodInfo methodInfo) +664911
     System.Web.Mvc.&lt;&gt;c__DisplayClass1.&lt;Execute&gt;b__0(ParameterInfo parameterInfo) +18
     System.Linq.WhereSelectArrayIterator</code>2.MoveNext() +85
     System.Linq.Buffer<code>1..ctor(IEnumerable</code>1 source) +217
     System.Linq.Enumerable.ToArray(IEnumerable<code>1 source) +78
     System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary</code>2 parameters) +133
     System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary<code>2 parameters) +27
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass42.&lt;BeginInvokeSynchronousActionMethod&gt;b__41() +28
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass8</code>1.b__7(IAsyncResult _) +12
     System.Web.Mvc.Async.WrappedAsyncResult<code>1.End() +57
     System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +50
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass39.&lt;BeginInvokeActionMethodWithFilters&gt;b__33() +58
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4f.&lt;InvokeActionMethodFilterAsynchronously&gt;b__49() +237
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass37.&lt;BeginInvokeActionMethodWithFilters&gt;b__36(IAsyncResult asyncResult) +12
     System.Web.Mvc.Async.WrappedAsyncResult</code>1.End() +57
     System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50
     System.Web.Mvc.Async.&lt;>c__DisplayClass2a.b__20() +24
     System.Web.Mvc.Async.&lt;>c__DisplayClass25.b__22(IAsyncResult asyncResult) +126
     System.Web.Mvc.Async.WrappedAsyncResult<code>1.End() +57
     System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +45
     System.Web.Mvc.&lt;&gt;c__DisplayClass1d.&lt;BeginExecuteCore&gt;b__18(IAsyncResult asyncResult) +14
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult ar) +25
     System.Web.Mvc.Async.WrappedAsyncResult</code>1.End() +62
     System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +61
     System.Web.Mvc.Async.&lt;>c__DisplayClass4.b__3(IAsyncResult ar) +25
     System.Web.Mvc.Async.WrappedAsyncResult<code>1.End() +62
     System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +49
     System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
     System.Web.Mvc.&lt;&gt;c__DisplayClass8.&lt;BeginProcessRequest&gt;b__3(IAsyncResult asyncResult) +28
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult ar) +25
     System.Web.Mvc.Async.WrappedAsyncResult</code>1.End() +62
     System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +49
     System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9042429
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +184</p>
  
  <p>Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1016</p>
  
  <h2>\</h2>
  
  <p><strong>Home controller:</strong></p>
  
  <pre><code> public ActionResult MyStores(double lat, double lng, string storename, string city, string state, string distributor, string channels)
      {
          MyStoresModel r = new MyStoresModel();
          r.stores = new List&lt;StoreDataModel&gt;();
          using (DisplayTrackingEntities ctx = new DisplayTrackingEntities())
          {
  </code></pre>
  
  <p>and I am trying to call it from my Index view as follows:</p>
  
  <pre><code>            &lt;input type="hidden" id="lat" name="lat" /&gt;
          &lt;input type="hidden" id="lng" name="lng" /&gt;
          &lt;div class="row"&gt;
              &lt;div class="form-actions"&gt;
                  &lt;button class="btn" onclick="return UseGPS();"&gt;Use GPS&lt;/button&gt;
                  &lt;button class="btn" onclick="return Search();"&gt;Search&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>