返回BadRequest(“ Failed”);时叫做我得到异常:
找不到方法:“ System.Net.Http.HttpResponseMessage System.Web.Http.Filters.HttpActionExecutedContext.get_Response()”。
更新的参考,重新启动的服务器,Visual Studio和计算机
[AllowAnonymous]
[HttpGet]
[HttpPost]
[Route("all")]
public async Task<IHttpActionResult> GetAllSettings(string t=null)
{
_logger.Info($"[GetAllSettings] token: {t}");
using (var db = new ExchangerDb())
{
var user = await db.Tokens.FirstOrDefaultAsync(x => x.Id == t);
if (user != null)
{
var result = Repo.GetAllSettings(new Guid(user.ClientId));
if (result != null)
{
return Ok(result);
}
}
}
_logger.Info($"[GetAllSettings] finished token: {t}");
return BadRequest("Failed");
}
预期会收到错误的请求,但我却收到异常,并在浏览器中显示
{“消息”:“发生错误。”}