3 of 3
Update answer
ND17
  • 5.2k
  • 9
  • 50
  • 78

You can write code in Helper/Data.php to get store url and using data helper call that method in admin page

for example

Helper/Data.php

public function getStoreUrl(){
    $storeId = $this->_storeManager->getDefaultStoreView()->getStoreId();
    $url = $this->_storeManager->getStore($storeId)->getUrl("sample/index/test");
return $url;

}

In admin page In block

public function __construct(
    \Namespace\Modulename\Helper\Data $_dataHelper
) {
    $this->_dataHelper = $_dataHelper;
}

get url - $this->_dataHelper->getStoreUrl();

In phtml

$block->helper('Namespace\Modulename\Helper\Data')->getStoreUrl();

For Magento 2.1

in block or phtml

echo $this->getBaseUrl().'sample/test/test'; 
ND17
  • 5.2k
  • 9
  • 50
  • 78