4

i created a simple controller like this:

namespace Namespace\Module\Controller\Confirm;

class Index extends \Magento\Framework\App\Action\Action
{

    protected $resultPageFactory;


    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
    ) {
        $this->resultPageFactory = $resultPageFactory;
        parent::__construct($context);
    }

    public function execute()
    {
        $params = $this->getRequest()->getParams();
        print_r($params);
        exit; 
    }
}

when i access my module controller with parameter like this, i'll get Page not found:

http://baseurl.com/mymodule/confirm/token/1231dasda

when i access my module contoller without parameter in url like this, it will run the controller function:

http://baseurl.com/mymodule/confirm

2

Try this, I think You should run

sudo php bin/magento setup:di:compile after adding new controller

    <?php 


    namespace Namespace\Module\Controller\Confirm;

    class Index
 extends \Magento\Framework\App\Action\Action
    {

        protected $resultPageFactory;


        public function __construct(
            \Magento\Framework\App\Action\Context $context,
            \Magento\Framework\View\Result\PageFactory $resultPageFactory
        ) {
            $this->resultPageFactory = $resultPageFactory;
            parent::__construct($context);
        }

        public function execute()
        {
            $params = $this->getRequest()->getParams();
            print_r($params);
            exit; 
        }
    }

    ?>

to access frontend

http://baseurl.com/module/confirm/index/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.