'ITC Custom Code - DW 11/16/2007 - Added to allow access to profiles without default.aspx.
' Note: this requires that the a rewrite rule such as follows is added to the ini file
' for the IIRF Isapi Rewriter.
' RewriteRule ^((/([^/.\?]+))*)/*$ /default.aspx?itctabpath=$1
' This regex pattern will send a username variable, which we will either need to look up
' (assuming we need to find a users page if users each have their own page) or at minimum, just
' short circuit the rest of this page since the URL is alreay in a form which the BeginRequest
' procedure can process.
If (Not Request.QueryString("itctabpath") Is Nothing) Then ' For now, we don't need to do anything here. If the system is updated so that each user
' has their own page, then we'll need to look up the TabId for the user's page here.
Dim itcTabPath As String = Request.QueryString("itctabpath").ToString() Dim objTC As New TabController
Dim intTabID As Integer
Dim PortalAlias As String = GetDomainName(Request, True)
Dim pc As PortalController = New PortalController
Dim portalID As Integer
Dim objTabInfo As DotNetNuke.Entities.Tabs.TabInfo
Dim objPortalAliasInfo As PortalAliasInfo = Nothing
Dim bChildPortal As Boolean = False
Dim _portalSettings As PortalSettings
'CHECK FOR CHILD PORTAL
'First check the PortalAlias collection to see if we are receiving a request for a child
'portal (eg. http://www.itcrossing.com/recreation).
'Get the PortalAliasCollection and prepare a portal alias which we will check to see if
'it exists.
Dim pac As PortalAliasCollection = DotNetNuke.Entities.Portals.PortalSettings.GetPortalAliasLookup()
Dim PotentialFullPortalAlias As String = PortalAlias & itcTabPath
'Check to see if potential child portal alias exists
If pac.Contains(PotentialFullPortalAlias) Then
'CHILD PORTAL
'If it does, then grab the PortalId and the PortalAliasInfo since we need these.
portalID = pac(PotentialFullPortalAlias).PortalID
objPortalAliasInfo = pac(PotentialFullPortalAlias)
bChildPortal = True
Else
'RESTful URL
'In the case of a RESTful URL, we retrieve the PortalId using GetPortalByAlias
Dim dr As IDataReader = CType(DataProvider.Instance().GetPortalByAlias(PortalAlias), IDataReader)
Try
If dr.Read Then
portalID = dr.GetInt32(dr.GetOrdinal("PortalID")) End If
Finally
If Not dr Is Nothing Then dr.Close()
End Try
bChildPortal = False
End If
'Retrieve the TabId based on the tab path for RESTful URLs Ignore if child portal
If Not bChildPortal Then
' This call isn't supported in older version of DNN, so we just use the
' implementation from recent version of DNN to retrieve the same data.
'intTabID = objTC.GetTabByTabPath(portalID, itcTabPath.Replace("/", "//"))
'For more recent versions of DNN (somewhere around 4.6 and higher), you can comment
'out the next 25 lines of code and uncomment the line above which starts with intTabID = ...
Dim strKey As String = itcTabPath.Replace("/", "//") Dim tabpathDic As Dictionary(Of String, Integer) = TryCast(DataCache.GetCache("itcTabPathCache"), Dictionary(Of String, Integer)) If tabpathDic Is Nothing Then
tabpathDic = New Dictionary(Of String, Integer)(StringComparer.CurrentCultureIgnoreCase)
Dim objTabController As New TabController
Dim arrTabs As ArrayList = objTabController.GetAllTabs()
For Each objTab As TabInfo In arrTabs
' add the TabPath and TabId to the TabPath Dictionary
If Not objTab.IsDeleted Then
If Not tabpathDic.ContainsKey(strKey) Then
tabpathDic(strKey) = objTab.TabID
End If
End If
Next
DataCache.SetCache("itcTabPathCache", tabpathDic, False) End If
'Get the TabId for this particular tab path.
If tabpathDic.ContainsKey(strKey) Then
intTabID = tabpathDic(strKey)
Else
intTabID = -1
End If
End If
'create a PortalAliasInfo object based on the PortalAlias so we can retrieve a PortalSettings
'object and tuck it away in the Context for retrieval in OnBeginRequest below.
If objPortalAliasInfo Is Nothing Then
objPortalAliasInfo = PortalSettings.GetPortalAliasInfo(PortalAlias)
End If
If Not objPortalAliasInfo Is Nothing Then
_portalSettings = New PortalSettings(intTabID, objPortalAliasInfo)
app.Context.Items.Add("PortalSettings", _portalSettings) End If
'Check to see if we have a TabId. If not, we get the default TabId for the child portal
'since the only reason we shouldn't have a TabId at this point is if we are here because of
'a request for a child portal rather than a request for a RESTful URL.
If intTabID <= 0 Then
'CHILD PORTAL
'Get the TabId from the portal settings object.
intTabID = _portalSettings.HomeTabId
'Rewrite the URL in the standard QueryString format.
RewriterUtils.RewriteUrl(app.Context, "~" & itcTabPath & "/" & glbDefaultPage & "?TabID=" & intTabID.ToString())
Else
'RESTful URL
'We already have the TabId, so just rewrite the URL in standard QueryString format
'Rewrite the URL in the standard QueryString format.
RewriterUtils.RewriteUrl(app.Context, "~/" & glbDefaultPage & "?TabID=" & intTabID.ToString())
End If
Else