In Symfony 2 I have the following code in my Controller:
// prepare to render the seller info panel
$response = array(
\'data\' => $data,
);
// rende
Latest way of doing POST request redirect (as of Symfony 2.6) is simply:
return $this->redirectToRoute('route', [
'request' => $request
], 307);
Code 307
preserves the request method, while redirectToRoute()
is a shortcut method.
I had the same error with you when I used $this->generateUrl
with passed parameters. However, my redirect worked when I tried this:
$this->get('router')->generate('route_name', array('param1' => 'paramVal'))
(I know it would not help you that much right now.)
It's impossible to redirect a POST request because the browser would have to re-send the POST data (which it doesn't). What you should do instead in this case is use forwarding.