AngularJS POST to .NET MonoRail Backend

Short post: if you’re trying to use AngularJS to $http.post() to a .NET MonoRail backend, you’ll find that there is nothing in Request.Form, or anywhere in the Request object.

I still have refactoring to do, but the quick solution is something like below. Note the headers object and transformRequest method. This needs refactored into a friendly service, but you get the idea for now.

$http({
    method: 'POST',
    url: '/YourUrl.rails',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    },
    transformRequest: function(data) {
        var postData = [];
        for (var prop in data)
            postData.push(encodeURIComponent(prop) + "=" + encodeURIComponent(data[prop]));
        return postData.join("&");
    },
    data: myPostData,
}).success(function (data, status) {
    console.log("success");
    console.log(data);
}).error(GLOBAL.YOUR_ERROR_HANDLER);