Today in this post we will found a solution for Request validation failed for action issue in Magento.
Sometime custom controller redirect to dashbord in magento admin panel
There are below method to solve this kind of issue.
Sulution 1.
Add below in your claass
use Magento\Framework\App\CsrfAwareActionInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\Request\InvalidRequestException;
and implements CsrfAwareActionInterface
class Edit extends Action implements CsrfAwareActionInterface { public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException { return null; } public function validateForCsrf(RequestInterface $request): ?bool { return true; } // excute method public function execute() { // your code } }
Solution 2.
In my solution was to have the route_id and frontName have the same value in route.xml
and layopt xml file starting from route_id
example: my route id and frontName is ib_code then layout xml file name will be ib_code_index.xml
Solution 3.
Add below method in your controller
protected function _isAllowed() { return true; }
Hope your issue will fix the Request validation failed for action issue!.
Related blogs – Admin Login Programmatically In Magento 2
Like us on Facebook