Magento 2.2.5 : Cant go to execute() in Controller
Make your controller extend \Magento\Framework\App\Action\Action
instead of \Magento\Backend\App\Action
, that should solve your issue.
EDIT :
It could also be the case you're trying to hit your controller directly and "Add Secret Key to URLs" feature is turned on at Stores > Configuration > Advanced > Admin > Security > Add Secret Key to URLs
. So basically it adds a key param in the URL which is always validated against the access to current resource. If the validation fails, it redirects to dashboard.
Try this code :
<?php
namespace Fudu\HelloWorld\Controller\Adminhtml\Student;
class Create extends \Magento\Backend\App\Action
{
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}
public function execute()
{
echo "controller call successfully";
exit;
}
}
You can't grant permission for new admin user on this controller, because when you extend Magento\Framework\App\Action\Action that mean by passing Magento Access Control list.
Please re-check these issues:
- acl.xml file
- make sure your you have _isAllowed function in your controller and return _authorization->isAllowed with resource id in acl.xml file.
- Try to Log out and re-login admin user.
Ex Admin Controller.
Class [Action Name] extends \Magento\Backend\App\Action
{
/**
* {@inheritdoc}
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed('[resource id in **acl.xml**]');
}
}