I'm getting this error when I call a Web API
method that returns a bool
(EDIT - any object, the error comes from the Hub attribute):
Error converting value True to type 'System.Web.Http.IHttpActionResult
This is the method:
[HttpGet]
[Hub(Name = "ServiceLog", IncomingMethod = "logIncoming", OutgoingMethod = "logOutgoing")]
[ResponseType(typeof(bool))]
public async Task<IHttpActionResult> TestMethodAsync(int i)
{
var result = await _repository.TestMethodAsync(i).ConfigureAwait(false);
return Ok(result);
}
EDIT: This is the offending code in the Hub attribute:
public override async void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
...
if (hub != null)
{
// THIS LINE THROWS THE ERROR
var response = await actionExecutedContext.Response.Content.ReadAsAsync(actionExecutedContext.ActionContext.ActionDescriptor.ReturnType);
hub.Clients.All.Invoke(OutgoingMethod, new { Time = DateTime.Now.ToString("G"), Data = response });
}
}
From Fiddler and browsers, I get back a 200 response and the correct return value, but Visual Studio throws an error. What is causing this error?