title: How can I log all query parameters in an action filter?
body: <p>I am implementing a logger that should capture details through an action filter for the purposes of user activity recording and fault finding.</p>
  
   
  
  <pre><code>   public interface ISessionLogger
      {
          void LogUserActionSummary(int sessionId, string userActionType);    
          void LogUserActionDetail(int session, string userActionType, DateTime userActionStartedUtc, long actionDurationInMilliseconds, string queryParams, string referredFrom);
      }
  </code></pre>
  
  <p>I would like <code>queryParams</code> to capture all keys and values from the form collection, route values, action params, json calls and the querystring, which sounds like I would need </p>
  
  <p><code>filterContext.Controller.ValueProvider</code></p>
  
  <p>but it doesn't seem possible to loop through this. So in my FilterAttribute I have </p>
  
  <pre><code>public void OnActionExecuting(ActionExecutingContext filterContext)
  {
      var paramList = new List&lt;string&gt;();
      if(filterContext.ActionParameters != null)
      {
          paramList.AddRange(filterContext.ActionParameters.Select(param =&gt; String.Format("{0}:{1}", param.Key, param.Value.ToString())));
      }
      if(filterContext.Controller.ValueProvider != null)
      {
          //loop through the valueprovider and save the key value pairs to paramList
      }
  
      _queryParams = string.Join(",", paramList);
  }
  </code></pre>
  
  <p>Is there another way to achieve this within the OnActionExecuting method of an action filter?</p>