title: CakePHP: _serialize not generating JSON response
body: <p>I'm using CakePHP v. 2.5.x...</p>
  
  <p>I am trying to write a controller action that can respond with and HTML view OR JSON. For some reason, no matter what I try, the response is an HTML page, not markup.</p>
  
  <p>This is in my <code>routes.php</code>:</p>
  
  <pre><code>Router::parseExtensions('json');
  </code></pre>
  
  <p>This is my controller action:</p>
  
  <pre><code>public function login() {
      $this-&gt;set('foo', 'bar');
      $this-&gt;set('_serialize', array('foo') );
  }
  </code></pre>
  
  <p>This returns the HTML for the <code>/users/login</code> view... NOT a JSON response.</p>
  
  <p>It's very confusing because I have a different action which works fine with a .json extension. What am I missing? </p>
  
  <p><strong>SOLVED!</strong></p>
  
  <p>Thanks to ndm for pointing out that I forgot to include <code>RequestHandler</code> in my components. </p>