0

I'm trying to create an admin route and the directories are:

app/code/<my_company>/<my_module_name>/Controller/Adminhtml/Index/Index

the code is


namespace Mastering\SampleModule\Controller\Adminhtml\Index;

use Magento\Framework\Controller\ResultFactory;

class Index extends \Magento\Backend\App\Action
{
    public function execute()
    {
        /** @var \Magento\Framework\Controller\Result\Raw $result */
        $result = $this->resultFactory->create(ResultFactory::TYPE_RAW);
        $result->setContents('Hello Admins!');
        return $result;
    }
}

and my routes.xml directory

app/code/Mastering/SampleModule/etc/Adminhtml/routes.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin">
        <route id="mastering" frontName="mastering">
            <module name="Mastering_SampleModule"/>
        </route>
    </router>
</config>

and after that I went to admin panel and disabled security keys. now i go to myhost/admin/mastering

and it returns

Magento Admin admin 404 Error Page not found.

my magento version is 2.4

0

from

app/code/<my_company>/<my_module_name>/Controller/Adminhtml/Index/Index

to

app/code/<my_company>/<my_module_name>/Controller/Adminhtml/RouterName/Index/Index

where RouterName = name which you specified in routes.xml

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.