我有一个像这样从 ControllerApi 继承的控制器(MVC 4)
public HttpResponseMessage<lightUserInfo> Post(LogOnModel model)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.UserName, model.Password))
{
MembershipUser user = Membership.GetUser(model.UserName);
var userinfo = new lightUserInfo(user);
return new HttpResponseMessage<lightUserInfo>(userinfo);
}
}
}
我可以看到对象 userinfo 填充得很好,这会向浏览器返回 200 OK ...但内容只是空 json {}
这是 CoffeeScript 中的客户端 ajax
$.ajax
url: Meshable.rooturl + "/api/authentication"
data: JSON.stringify authenticationDetails
dataType: "json"
type: "POST"
contentType: 'application/json; charset=utf-8'
error: (e) ->
success: (data) ->
#data comes in as empty {}