I want to redirect customer to login page in my controller without using observer. here is my code
protected $urlInterface;
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\App\Response\RedirectInterface $redirect,
\Magento\Framework\UrlInterface $url,
\Magento\Framework\App\ResourceConnection $resource,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Customer\Model\Session $customerSession,
\Magenticians\Evaluation\Model\EvaluationFactory $EvaluationFactory,
\Magenticians\Evaluation\Model\Evaluation $eval,
\Magenticians\Evaluation\Model\ResourceModel\Evaluation\Collection $evaluationCollection,
\Magento\Framework\Controller\ResultFactory $result)
{
parent::__construct(
$context
);
$this->EvaluationFactory = $EvaluationFactory;
$this->_customerSession = $customerSession;
$this->_storeManager = $storeManager;
$this->resultRedirect = $result;
$this->_resource = $resource;
$this->_evaluation =$eval;
$this->_evaluationCollection = $evaluationCollection;
$this->redirect = $redirect;
$this->urlInterface = $url;
}
// Create login URL
$login_url = $this->urlInterface
->getUrl('customer/account/login');
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setUrl($login_url);
$this->_view->loadLayout();
$this->_view->getLayout()->initMessages();
$this->_view->renderLayout();
but as result i have no redirection response please help me and thanks in advance