title: OutputCache with VaryByCustom not working
body: <p>I'm trying to implement caching in ASP.NET MVC 4 using the OutputCache attribute.</p>
  
  <p>Here is my controller action:</p>
  
  <pre><code>[HttpGet]
  [OutputCache(Duration = CACHE_DURATION, VaryByCustom = "$LanguageCode;myParam", Location = OutputCacheLocation.Server)]
  public JsonResult MyAction(string myParam)
  {
      // this is called also if should be cached!
  }
  </code></pre>
  
  <p>And here is the GetVaryByCustomString in the Global.asax:</p>
  
  <pre><code>public override string GetVaryByCustomString(HttpContext context, string arg)
  {
      var pars = arg.Split(';');
      if (pars.Length == 0) return string.Empty;
  
      var res = new System.Text.StringBuilder();
      foreach (var s in pars)
      {
          switch (s)
          {
              case "$LanguageCode":
                  var culture = CultureManager.GetCurrentCulture();
                  res.Append(culture.Name);
                  break;
              default:
                  var par = context.Request[s];
                  if (par != null)
                      res.AppendFormat(par);
                  break;
          }
      }
      return base.GetVaryByCustomString(context, res.ToString());
  }
  </code></pre>
  
  <p>This method is always called and returns the right value (e.g. <code>"it123"</code>).</p>
  
  <p>If I call the action with the only <code>myParam</code> parameter, the cache works correctly.</p>
  
  <pre><code>http://localhost:1592/MyController/MyAction?myParam=123 // called multiple times always read from cache
  </code></pre>
  
  <p>The problem is that when I call the action with another parameter, not included in the <code>VaryByCustom</code> string, the controller action is called anyway, also if is should be cached and the <code>GetVaryByCustomString</code> returns the same result.</p>
  
  <pre><code>http://localhost:1592/MyController/MyAction?myParam=123&amp;dummy=asdf // called multiple times with different 'dummy' values always calls the action
  </code></pre>
  
  <p>Any idea?</p>