为什么我在调用web api控制器中的post方法时会出错?

时间:2016-09-20 17:37:22

标签: angularjs asp.net-web-api

我有这个angularjs服务:

function checkCredentials(username,password) {
    return $http.post(config.baseUrl + "api/login/", username, password)
}

这个网页api:

public class LoginController : ApiController
{
    private MorenoContext _context;

    public LoginController()
    {
        _context = new MorenoContext();
    }

    [HttpPost]
    public async Task<IHttpActionResult> Post(string username, string password)
    {
        return Ok("test");
    }

    protected override void Dispose(bool disposing)
    {
        if (disposing)
        {
            _context.Dispose();
        }
        base.Dispose(disposing);
    }
}

但是当在checkCredentials()客户端函数的帮助下尝试调用web api方法时,我收到此错误:

Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/myProjectName/api/login/

知道我为什么会收到错误吗?

0 个答案:

没有答案