title: ASP.NET Core Get Request Body from ActionExecutedContext ActionFilter
body: <p>I am trying to get the body of a POST Request in an ActionFilterAttribute. The bodyString is returned empty without getting any exceptions. I am testing this with a simple { "name": "value" } JSON.</p>
  
  <pre><code>public override void OnActionExecuted(ActionExecutedContext context)
      {
          string bodyString = string.Empty;
  
              using (System.IO.MemoryStream m = new System.IO.MemoryStream())
              {
                  try
                  {
                      if (context.HttpContext.Request.Body.CanSeek == true)
                          context.HttpContext.Request.Body.Position = 0;
  
                      context.HttpContext.Request.Body.CopyTo(m);
  
                      bodyString = Encoding.UTF8.GetString(m.ToArray());
                  }
                  catch (Exception ex)
                  {
                      Console.WriteLine(ex.Message);
                  }
              }
          }
      }
  
      base.OnActionExecuted(context);
  }
  </code></pre>