0

So I'm trying to make a call to this specific method:

[HttpGet]
public int GetLogin(string u, string p)
{
    UserLogin uL = new UserLogin();
    return (int)uL.Authenticate(u, p);
}

However it keeps calling this method in my Controller instead:

public IEnumerable<string> Get()
{
    return new string[] { "value1", "value2" };
}

^^ Which is the generated code in the Controller.

Here Angular code for my factory and, more importantly, my URI:

var loginFactory = angular.module('loginService', ['ngResource'])

loginFactory.factory('UserLogin', function ($resource) {
    return $resource('api/login?:username?:password', {}, {
        query: {
            method: 'GET',
            params: { username: 'hunter', password: 'hunter' },
            isArray:true
        }
    });
});

Any insight would be much appreciated. Thanks.

hunt
  • 78
  • 1
  • 10

2 Answers2

1

Change your resource to this:

$resource('api/GetLogin?u=:username&p=:password', {}, {  // if that's the right route
    query: {
        method: 'GET',
        params: { username: 'hunter', password: 'hunter' },
        isArray:true
    }
});
lucuma
  • 18,247
  • 4
  • 66
  • 91
0

Is your request going like api/login?username=something&password=something...? if yes, the parameter names on the action should match the query string parameter names:

public int GetLogin(string **username**, string **password**)

Kiran
  • 56,921
  • 15
  • 176
  • 161
  • Are you saying that my parameter names in my GetLogin(string username, string password)? And that those parameter names need to match my params: names in my factory? – hunt May 17 '13 at 23:20