I know this is very basic, but I'm starting now. I'm creating a neighborhood registry, using AngularJS, my backend is in C # with ASP.NET MVC. My method is called by view , but does not get JSON:
This is my save method on BairroController
:
//[HttpPost]
public dynamic save(string bairro)
{
string user = "100";
string pass = "a";
int idEmp = 1;
master = new ClassMaster();
BairroModel BairroModel = new BairroModel();
BairroDTO BairroDto = new BairroDTO();
return BairroDto.save(BairroModel, user, pass, master.contexto, BairroModel.t0020_id_empresa = idEmp);
}
This is Ajax Saving:
$scope.AddBairro = function (bairro) {
$http.post("http://localhost:23714/Bairro/save", bairro).success(function (data) {
//delete $scope.contatos;
$scope.contaroForm.$setPristine();
console.log(bairro);
});
};
Problems:
-
When I click Save, my method is called, but the parameter receives
null
. See the example here . -
The method is called twice and in the firefox console and you can see what was sent, in this case, a
OPTIONS
and aPOST
why? but in neither case does the method catchjson
. -
In this link you can see that
json
was actually sent, you can also seePOST
andOPTIONS
. -
In the Backend, this part is commented out, if "uncommented", the method is not called.