Reputation: 10174
I have an HttpPost action as below:
[HttpPost]
public string GetPerson()
{
string output = GetPerson();
return output;
}
I am returning xml as a string. Is it possible read this string in actionfilter OnResultExecuted or OnResultExecuting methods?
Upvotes: 5
Views: 3405
Reputation: 17680
On each of these actionfilters you can get the result (an ActionResult
object).
For OnResultExecuted
you can get it from the ResultExecutedContext.Result
property
I've added a sample below.
public class InterceptValueAttribute : ActionFilterAttribute
{
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
var result = filterContext.Result as ContentResult;
var data = result.Content;
//use data as required
}
}
You can use it on your action as below.
[HttpPost]
[InterceptValue]
public string GetPerson()
{
string output = GetPerson();
return output;
}
Upvotes: 3