1

I don't why my admin controller is not working, I have checked it and everything seems to be ok.

This is my code:

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="testpakke" frontName="testpakke">
            <module name="Company_Pakke" before="Magento_Backend" />
        </route>
    </router>
</config>

Controller/Adminhtml/Download/PDF.php

<?php

namespace Company\Pakke\Controller\Adminhtml\Download;
use Magento\Backend\App\Action;

class PDF extends Action
{
    /**
     * @var PageFactory
     */
    protected $resultPageFactory;

    /**
     * @param Context $context
     * @param PageFactory $resultPageFactory
     */

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

    /**
     * Index action
     *
     * @return \Magento\Backend\Model\View\Result\Page
     */
    public function execute()
    {

        return  $resultPage = $this->resultPageFactory->create();
    }

}

when I type http://store/admin_1evvgb/testpakke/download or http://store/admin_1evvgb/testpakke/download/pdf or http://store/admin_1evvgb/testpakke/Adminhtml/download/pdf I get always the 404 error Page not found. Am I typing the path correctly?

Greetings!

1
  • Please share your menu.xml code.
    – Pawan
    Jan 4, 2020 at 6:20

2 Answers 2

3

It is naming convention issue. Please rename your controller action PDF to Pdf and run setup:upgrade and di : compile. And check route http://store/admin_1evvgb/testpakke/download/pdf

Hope it will help you.

Thank you

0

In my case, I implemented HttpGetActionInterface for Controller, but my request type was "Post". After changing the implementation to HttpPostActionInterface it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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