Angularjs et ASP.NET l'Api Web de provoquer 500 Erreur Interne du Serveur sur $http.post

Je suis en utilisant Angularjs et ASP.NET l'Api Web, mon $http.get, $http.mettre et $http.supprimer fonctionnent très bien, mais quand je l'appelle $http.post-je obtenir 500 Erreur Interne du Serveur, voici mon code:

Mon Angularjs Contrôleur insérer une fonction:

$scope.insert = function () {
    var data = '{ "Id": "1", "Name": "test", "Category": "r", "Price": "456.00" }';

    $http.post('api/products', data).success(function (data) {
        alert("it works");

    }).error(function () {
        console.log(Error);
        alert('Error reading JSON file. - ' + data);
    });   
 }

Mon modèle en C#:

public class Product
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Category { get; set; }
        public decimal Price { get; set; }
    }

Mon contrôleur en C#:

    public class ProductsController : ApiController
    {
       public void PostProduct(Product product)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product is NULL");
            }

            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand();
                cmd = new SqlCommand("INSERT INTO [AdventureWorks2012].[Production].[Product2] ( [Name], [ListPrice], [ProductLine]) VALUES ('" + product.Name + "', '" + product.Price + "', '" + product.Category + "')", con);

                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

        }
    }

Code n'atteint jamais le frein de points en C# contrôleur et la lance 500 Erreur Interne du Serveur.

Veuillez en informer.

  • Veuillez fournir l'itinéraire de configuration.