mvc api 拦劫处理返回值

///


/// 重写回传的处理
///

///
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
// 
//if ( actionExecutedContext.ActionContext != null )
//{
// var mm = (actionExecutedContext.ActionContext.Response.Content as ObjectContent).Value;
 
//重新封装返回值
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new ObjectContent(result.GetType(), result, new JsonMediaTypeFormatter())
};
actionExecutedContext.Response = response;
}
base.OnActionExecuted(actionExecutedContext);
}

你可能感兴趣的:(mvc api 拦劫处理返回值)