获取网页API过滤
问题描述:
我试图让我的modeltype是从控制器的在actionfilter操作返回型号类型响应。获取网页API过滤
我试图在actionExecutedContext.Response对象看,但我无法找到任何东西。
答
public class FooFilter : ActionFilterAttribute {
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) {
var objectContent = actionExecutedContext.Response.Content as ObjectContent;
if (objectContent != null) {
var type = objectContent.ObjectType; //type of the returned object
var value = objectContent.Value; //holding the returned value
}
}
}
你能后,你已经尝试过的任何代码? – ragerory