Hi, Ralph:

Thanks for taking the time to check this out and for the lead.

$response->sendHeaders() seems to have done it.

I see what you mean about setRedirect(); Is there a better way than using
Response's setRedirect() method? Maybe something that has a signature like
this:
setRedirect($controller, $action)

Thanks!
Greg




Ralph Schindler-2 wrote:
> 
> Hmm. $response->setRedirect() assumes you are providing it a url so its 
> probably best if that were an absolute path.
> 
> Also, it does not stop the dispatchloop from executing, so you might 
> have to do $request->setDispatched(true);
> 
> To get a sense of how redirecting is handled, you might want to have a 
> look at the Redirector action helper:
> 
> http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Controller/Action/Helper/Redirector.php
> 
> specifically, have a look at gotoUrl() as well as redirectAndExit()
> 
> -ralph
> 
> 
> Gregorio wrote:
>> Hello, everybody:
>> 
>> I've got a controller helper plugin that has a preDispatch method in it.
>> 
>> It's checking to see if the user has logged in via an off-site
>> authentication service, and if not, redirects the user to an
>> Authentication
>> controller do that part of the work.
>> 
>> However, the redirect isn't working. I took a look at the header stack
>> and
>> it wasn't there. However, if I add a dummy header, it works. Here's some
>> code to help explain:
>> 
>> 
>> class Plugin_CasAuth extends Zend_Controller_Plugin_Abstract
>> {
>>    
>>     public function preDispatch(Zend_Controller_Request_Abstract
>> $request)
>>     {
>>         $request = $this->getRequest();
>>         $response = $this->getResponse();
>>         $session = new Zend_Session_Namespace('Zend_Auth');
>> 
>>         // No need for any more processing if this is the Authenticate
>> controller.
>>         if ('authenticate' === $request->getControllerName()) {
>>             return true;
>>         }
>>              
>>         if (empty($session->storage))
>>         {
>>             $response->setRedirect('authenticate');
>>             // If I comment the following line, there's no redirect. User
>> gets sent
>>             // directly to the main index controller.
>>             $response->setHeader("Test", "This is a test!");
>>         }
>>     }
>> }
>> 
>> 
>> The problem is in the last if block.
>> 
>> Any ideas?
>> 
>> Thanks!
>> Greg 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Problem-with-setRedirect%28%29----it%27s-not-redirecting-tp25193870p25231923.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to