title: AngularJS nullable parameter missing in ASP.NET Web Service method
body: <p>I am calling an ASP.NET Web Service Method with a nullable optional paramter  from an AngularJS controller. It works fine if I provide the parameter value but don't work if the parameter value is not provided!! and shows he following error:</p>
  
  <p><strong><em>Failed to load resource: the server responded with a status of 500 (Internal Server Error)</em></strong></p>
  
  <p>and In details:</p>
  
  <pre><code>System.InvalidOperationException: Missing parameter: name.
     at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
     at System.Web.Services.Protocols.UrlParameterReader.Read(HttpRequest request)
     at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
     at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
  </code></pre>
  
  <p><strong>Here is Web service Method:</strong></p>
  
  <pre><code>[WebMethod]
          public void GetAllStudents(string name)
          {
              IQueryable&lt;Student&gt; listStudents = dbContext.Students;
              if (!String.IsNullOrEmpty(name))
              {
                  listStudents = listStudents.Where(x =&gt; x.name.Contains(name));
              }
  
              JavaScriptSerializer js = new JavaScriptSerializer();
              Context.Response.Write(js.Serialize(listStudents.ToList()));
          }
  </code></pre>
  
  <p><strong>Here is My Route Config:</strong></p>
  
  <pre><code>  $routeProvider.when("/students/:name?",
          {
              templateUrl: "Templates/Students.html",
              controller: "studentsController",
  
          })
  </code></pre>
  
  <p><strong>Here is My Controller:</strong></p>
  
  <pre><code>.controller("studentsController", function ($scope, $http, $route, $location, $routeParams) {
          $scope.message = "Student Page";
  
          $scope.studentSearch = function () {
              if ($scope.name) {
                  $location.url("/students/" + $scope.name);
              }
              else {
                  $location.url("/students");
              }
          }
  
          if ($routeParams.name) {
              $http({
                  method: "GET",
                  url: "StudentService.asmx/GetAllStudents",
                  params: { name: $routeParams.name }
              })
             .then(function (response) {
                 $scope.students = response.data;
             })
          }
          else {
              $http.get("StudentService.asmx/GetAllStudents")
              .then(function (response) {
                  $scope.students = response.data;
              })
          }
  
      })
  </code></pre>
  
  <p><strong>*Any Help please!!</strong></p>