title: Asp.NET MVC ActionFilter cannot get Form Submit data
body: <p>I want to use custom action filter to manipulate parameters to one action.</p>
  <p>User inputs: 2 names in a form ;</p>
  <p>Action: actually needs to take 2 ids;</p>
  <p>Action Filter (onExecuting, will verify the input names and if valid, convert them into 2 ids and replace in the routedata)</p>
  <p>because i don't want to put validation logic in Action Controller.</p>
  <p>here's part of the code:</p>
  <ol>
  <li><p>Routing Info</p>
  <pre><code>routes.MapRoute(
       &quot;Default&quot;, // Route name
       &quot;{controller}/{action}&quot;, // URL with parameters
       new { controller = &quot;Home&quot;, action = &quot;Index&quot;} // Parameter default
  );
  
  routes.MapRoute(
       &quot;RelationshipResults&quot;,  // Route Name
       &quot;Relationship/{initPersonID}/{targetPersonID}&quot;,  // URL with parameters
       new { controller = &quot;Relationship&quot;, action = &quot;Results&quot; }
  );
  </code></pre>
  </li>
  <li><p>Form to submit (Create 2 input box and submit via jquery)</p>
   
       
      ...
  <pre><code>     &lt;td align=&quot;left&quot;&gt;&lt;%: MvcWeibookWeb.Properties.Resource.Home_InitPersonName%&gt;&lt;/td&gt;
       &lt;td align=&quot;right&quot;&gt; &lt;%= Html.TextBox(&quot;initPersonID&quot;)%&gt;&lt;/td&gt;
       &lt;td rowspan=&quot;3&quot; valign=&quot;top&quot;&gt;
           &lt;div id=&quot;sinaIntro&quot;&gt;
           &lt;%: MvcWeibookWeb.Properties.Resource.Home_SinaIntro %&gt;
           &lt;br /&gt;
           &lt;%: MvcWeibookWeb.Properties.Resource.Genearl_PromotionSina %&gt;
           &lt;/div&gt;
       &lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
       &lt;td align=&quot;left&quot; width=&quot;90px&quot;&gt;&lt;%: MvcWeibookWeb.Properties.Resource.Home_TargetPersonName%&gt;&lt;/td&gt;
       &lt;td align=&quot;right&quot;&gt;&lt;%= Html.TextBox(&quot;targetPersonID&quot;)%&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
       &lt;td colspan=&quot;2&quot; align=&quot;right&quot;&gt;
           &lt;a href=&quot;#&quot; class=&quot;btn-HomeSearch&quot; onclick=&quot;$('#formSearch').submit();&quot;&gt;&lt;%: MvcWeibookWeb.Properties.Resource.Home_Search%&gt;&lt;/a&gt;
       &lt;/td&gt;
  </code></pre>
  </li>
  <li><p>Action Filter</p>
  <pre><code> public override void OnActionExecuting(ActionExecutingContext filterContext)
   {
       Sina.Searcher searcher = new Sina.Searcher(Sina.Processor.UserNetwork);
       String initPersonName, targetPersonName;
  
       // form submit names, we need to process them and convert them to IDs before it enters the real controller.
       initPersonName = filterContext.RouteData.Values[&quot;initPersonID&quot;] as String;
       targetPersonName = filterContext.RouteData.Values[&quot;targetPersonID&quot;] as String;
   // do sth to convert it to ids and replace
  </code></pre>
  </li>
  <li><p>Action/Controller</p>
  <pre><code> [ValidationActionFilter]
       [HandleError]
       public ActionResult Results( Int64 initPersonID, Int64 targetPersonID)
       { ...
  </code></pre>
  </li>
  </ol>
  <p>My problem is: in the actionFilter, it never gets the 2 parameters &quot;initPersonID&quot; and &quot;targetPersonID&quot;, the RouteData.Values don't contain these 2 keys.</p>