ich versuche, Daten von AngularJS zu ASP.net MVC zu übergeben und wird immer Null. Hier ist mein Code (nur die wesentliche, Button, Regler und C# Posting:
HTML:
<a class="btn btn-grey btn-lg btn-block" ng-click="AddCar()">Save</a>
-Controller
$scope.AddCar = function() {
$http.post("Cars/AddCar", JSON.stringify($scope.new.JsonCar)).success(function (data) {
Alert(ok)
})
C#
public string AddCar(string JsonCar)
{
try
....
}
In JSON.stringify ($ scope.new.JsonCar) Ich bekomme das:
"{" Name ":" FIAT 500" , "Beschreibung": "Neues Auto", "MaxUserCapacity": 5, "PhotoPath": "none"}“
Was i‘ m falsch machen?
yah, das ist es. Vielen Dank :) – Luis
Perfekt! Glücklich, ich könnte helfen. –
es funktioniert, weil es jetzt die 'contentType:" application/json "' – VahidN