Skip to main content
1 of 2

Magento 2: Controller Invalid return type for Account Controller

Just wrote the following controller:

namespace MySite\MyCustomModule\Controller\Dashboard;

use Magento\Customer\Controller\AccountInterface;
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\View\Result\PageFactory;

class Index implements AccountInterface, HttpGetActionInterface
{
    /**
     * @var PageFactory
     */
    protected $resultPageFactory;

    /**
     * @param PageFactory $resultPageFactory
     */
    public function __construct(
        PageFactory $resultPageFactory
    ) {
        $this->resultPageFactory = $resultPageFactory;
    }

    /**
     * Default customer account page
     *
     * @return \Magento\Framework\View\Result\Page
     */
    public function execute()
    {
    
        return $this->resultPageFactory->create();
    }
}

However, when trying to get results,

also di.xml

router id="standard" route id="customer" module name="MySite_MyCustomModule" after="Magento_Customer" route router

go to the needed route http://mysite.lo/customer/dashboard and get the following issue:

1 exception(s): Exception #0 (InvalidArgumentException): Invalid return type

Exception #0 (InvalidArgumentException): Invalid return type

#1 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:31]

and even debug cannot log in to method execute.

Does anyone face this issue?