title: How do I pass parameters from action filters to the controllers actions in MVC?
body: <p>It has been a day trying to figure out how to pass parameters from action filter to the controllers actions but with no luck. I have been to <a href="https://stackoverflow.com/questions/1809042/asp-net-mvc-pass-object-from-custom-action-filter-to-action">this</a> SO question and tried both of the answers. 
  When I debug my application I don't get a value for my controller action parameter it is always null.</p>
  
  <p>Here is the action filter...</p>
  
  <pre><code>public class FacebookCheckPermission : ActionFilterAttribute
      {
          public string redirectURL { get; set; }
          public async  override void OnActionExecuting(ActionExecutingContext filterContext)
          {
                  var myBaseController = (BaseController)filterContext.Controller;
                  PermissionRequestViewModel permissionViewModel = myBaseController.GetMissingPermissions();
  
                  filterContext.RouteData.Values.Add("Value1", "Hi");
  
                  filterContext.ActionParameters["Value2"] = "Bye";
  
                  if (permissionViewModel != null &amp;&amp;
                      permissionViewModel.MissingPermissions.Count &gt; 0)
                  //Code removed for brevity.
  
                  base.OnActionExecuting(filterContext);
          }
  
      }
  </code></pre>
  
  <p>And here is the Controller Action:</p>
  
  <pre><code>[FacebookCheckPermission]
  public async Task&lt;ActionResult&gt; Index(string Value1, string Value2)
  {
  </code></pre>
  
  <p><strong>UPDATE</strong>
  Seems that I have found the problem. The problem is that my Action filter is <code>async</code> and I have some API calls to facebook. I can get my action filter parameter if I declare it anywhere before the API calls but when I declare it under an API call my action parameter become null. What could be the problem?</p>
  
  <p>Here is the call to facebook graph API.
  dynamic myInfo = await <code>fb.GetTaskAsync("me?fields=id,first_name,last_name,link,locale,email,name,birthday,gender,location,age_range,about".GraphAPICall(appsecret_proof));</code></p>