Member Avatar


For my angular controller I have:

app.controller('AdminCtrl', function ($scope, $http) {
    $ = {
        Name: '',
        Password: ''

    $scope.login = function (data) {
            method: 'POST',
            url: '/login/postlogin',
            data: JSON.stringify({
                data: $
            contentType: "application/json",
            dataType: "json"
        }).success(function (data) {
        }).error(function (error) {

For my c# controller I have a very basic setup:

        public string PostLogin(string data) {          
            return string.Empty;

My issue is that inside of the c# controller, data is always null. Does anyone know how to pass the name and password params over to the c# controller? I know for a fact that I am recieving values for them from my textboxes that I have. Thanks!

I will recieve the success message/alert.

Member Avatar


I finally recieved an answer for this. Basically what needed to be done was to create a couple properties:

public class Data {
            public string Name { get; set; }
            public string Password { get; set; }

And then:

        public object PostLogin(Data data) {
            return string.Empty;

After these edits I was able to pass objects from AngularJS to a C# controller. Hopefully this will help somebody one day.