title: How to perform save in ASP.Net using angularjs
body: <p>I'm trying to save data to DB. The breakpoint is not hit in code behind and the data is not saved. All I see in the console log is - <code>PASS : [object Object]</code>. Where am i going wrong.</p>
  
  <p><strong>default.aspx:</strong></p>
  
  <pre><code>&lt;div data-ng-controller="defaultCtrl"&gt;
          Username
          &lt;input type="text" id="txtUsername" data-ng-model="AdminUser.Username" /&gt;
          &lt;br /&gt;
          Password
          &lt;input type="text" id="txtPassword" data-ng-model="AdminUser.Password" /&gt;        
          &lt;br /&gt;
          &lt;button type="submit" data-ng-click="AddUser(AdminUser)"&gt;Submit&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>default.aspx.cs:</strong>
  <strong>class:</strong></p>
  
  <pre><code>public class AdminUser
      {
          public string Username { get; set; }
          public string Password { get; set; }        
      }
  
  [WebMethod]
  [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
          public void AddUser(AdminUser adminUser)
          { --breakpoint set here but not hit
  
              --code to save data
              AdminUserDB.AddUser(adminUser);
          }
  </code></pre>
  
  <p><strong>defaultCtrl.js:</strong></p>
  
  <pre><code>app.controller("defaultCtrl",["$scope","DefaultFactory",function ($scope,DefaultFactory){
  $scope.AddUser = function (AdminUser) {
  var promise = DefaultFactory.AddUser(AdminUser);
          promise.then(function (success) {
              console.log("PASS : " + success);
  },
          function (error) {
              console.log("ERR : " + error);
          })
      }
  }]);
  </code></pre>
  
  <p><strong>defaultFactory.js:</strong></p>
  
  <pre><code>app.factory("DefaultFactory", ["$http", function ($http) {
      var Factory = {};
      //add new user
      Factory.AddUser = function ($params) {   
          //console.log($params); -- i can see the object with the data in console.     
          return $http({
              url: "http://localhost:49271/default.aspx/AddUser",
              method: "GET", --when i put POST here, there is an error in console
              data: $params            
          })
              .success(function (data, status) {
          })
              .error(function (data, status) {
                  console.log("DATA : " + data);
                  console.log("STATUS : " + status);
          });
      };    
      return Factory;
  }]);
  </code></pre>