开发者

Zend Framework: Redirect from Controller Plugin which is more efficient

开发者 https://www.devze.com 2023-01-09 16:38 出处:网络
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 th

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消