As you know, the simple method GetTab(int tabid) was obsolete and has been replaced by GetTab(ByVal TabId As Integer, ByVal PortalId As Integer, ByVal ignoreCache As Boolean). If you want to call the new method, we have to pass the additional parameter “PortalId”.
In common, the object PortalSettings can be easy to get with DNN context, such as special dnn module & page; however, it may be inaccessible in some sceneries, such as separate aspx page or handler. Then is there any way to get the correct tab info with this new method? Now there is a simple trick to do it with passing into Null.NullInteger as the parameter PortalId. So the coding looks like that:
var tabController = new TabController();
var blogPage = tabController.GetTab(tabID, Null.NullInteger, false);
Deeping into the source code, you will find out that it always tries to get the correct PortalId for this tab/page object:
//if we do not know the PortalId then try to find it in the Portals Dictionary using the TabId
portalId = GetPortalId(tabId, portalId);
//if we have the PortalId then try to get the TabInfo object
tab = GetTabsByPortal(portalId).WithTabId(tabId) ??
GetTabsByPortal(GetPortalId(tabId, Null.NullInteger)).WithTabId(tabId);
Hope this trick & tip helps if someone has the same issue.