我刚刚将 MVC4 WebAPI 从 beta 更新为 RC,现在这部分代码不起作用。我从这里读到: http ://social.msdn.microsoft.com/Forums/en-US/wcf/thread/e90d582a-7023-44a1-b311-4fe1370b0314/我必须使用
Request.CreateResponse(HttpStatusCode.OK, Response)
但是没有CreateResponse
哪个实现需要两个参数?所以我想知道我应该如何继续修复这部分?
public HttpResponseMessage<Response> Login(string username, string password)
{
ApiResponse<string> user = am.LogOn(username, password);
System.Diagnostics.Debug.WriteLine(username + " - " + password);
System.Diagnostics.Debug.WriteLine("User status is: " + user.Status);
switch (user.Status)
{
case ResponseStatus.OK:
System.Diagnostics.Debug.WriteLine(user.Value);
return new HttpResponseMessage<Response>(new Response { Token = user.Value, ValidTo = user.ValidTo });
default:
return new HttpResponseMessage<Response>(HttpStatusCode.Forbidden);
}
}