none
AngularJS Post İşlemi

    Soru

  • Merhaba,
    AngularJS ile post işlemi yaparken aşağıdaki hatayı alıyorum:
    OPTIONS http://localhost:50596/api/addCategory
    XMLHttpRequest cannot load http://localhost:50596/api/addCategory. Response for preflight has invalid HTTP status code 405

    Web API
            public void create(Category category)
            {
                Category cat = new Category();
                cat.CategoryName = category.CategoryName;
                db.Categories.InsertOnSubmit(cat);
                db.SubmitChanges();
            }

    JS

        $scope.addCategory = function () {
            var Category = {
                CategoryName:$scope.CategoryName,
            };
            $http({
                method: 'POST',
                url: 'http://localhost:50596/api/addCategory',
                data: Category,
                headers: {
                    'Content-Type': 'application/json'
                }
            }).success(function () {
                console.log("Eklendi");
            }

    HTML

                <input ng-model="CategoryName" />
                <button ng-click="addCategory()" />

     
    12 Nisan 2016 Salı 13:05