i seen from here 2 ways to redirect from a controller plugin ... i wonder which is more efficient. i am wondering in the 2nd method, it maybe slower because the response is created? what happens in the 1st method tho? it will redirect immediately开发者_StackOverflow?
$request->setModuleName('default')
->setControllerName('search')
->setActionName('form')
->setDispatched(false);
or
$this->_response->setRedirect('redirecturl');
The first method is an application redirect: You define that the requested operation is within another controller, so the same http request is used to execute the action.
The second method is an http redirect: The http-response will have an http-location-redirect, so the client will fire a second a http-request to get the result.
The first is definetly the most efficient.
PS: You can call the forward-method of the controller to dispatch another action.
精彩评论