2012-10-06 6 views

cevap

37

Döndürülen değeri Response.Content özelliği aracılığıyla alabilirsiniz. cevap için

public class MyFilterAttribute : ActionFilterAttribute 
{ 
    public override void OnActionExecuted(HttpActionExecutedContext context) 
    { 
     var objectContent = context.Response.Content as ObjectContent; 
     if (objectContent != null) 
     { 
      var type = objectContent.ObjectType; //type of the returned object 
      var value = objectContent.Value; //holding the returned value 
     } 
    } 
} 
+0

Teşekkür: eylem bir nesne döndürdü Eğer döndürülen değerin gerçek örneğini alabilirsiniz yerden ObjectContent yayınlayabilmek için. Context.Response.Content türünün türü System.Net.Http.ObjectContent > 'dır. Ben sadece System.Collections.Generic.IEnumerable 'bölümünü istiyorum. Bunu nasıl alabilirim? –

+0

'ObjectContent ' 'ObjectContent' türetilmiştir, bu nedenle sadece 'objectContent'için context.Response.Content' öğesini çeviriniz, sonra' 'Value' özelliği 'IEnumerable ' 'a çevirebilirsiniz. . – nemesv