I am trying to create a custom controller in magento 2.1. I have created routes.xml and namespace as
routes.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
<router id="standard">
<route id="customattribute" frontName="customattribute">
<module name="Namespace_Modulename" />
</route>
</router>
</config>
controller
namespace namespace\modulename\Controller\Searchajax;
class Index extends \Magento\Framework\App\Action\Action
{
/**
* say hello text
*/
public function execute()
{
return 'Hello world!';
}
}
in my controller file. But I am not getting the required result. Please suggest to me a way to do this. Thanks in advance.