Problem: If a user other than host is logged into a child portal, accessing any ASPX page without a querystring parameter of "tabid" of "alias" causes the user to be logged off. This problem usually becomes apparent when third-party controls such as editors, image galleries, file downloaders refer to ASPX pages from popup dialogs or windows.
Versions affected: DNN 1.0.9, DNN 1.0.10, DNN 2.0.x
Cause: The core portal detection engine relies on the domain from the URL or one of the two querystring parameters to identify the portal. Most of the time, one of these parameters is present, however, when a non-core ASPX page is called this is not always the case. In this situation, the engine incorrectly identifies the portal as the parent portal in the Application_BeginRequest handler. When Application_AuthenticateRequest is fired, the identified portal is different from the authenticated user's portal and so the user is logged out.
Solution: Set a cookie from the child portal's default page called "portalalias" with a value set to the child portal's alias. Add code to Application_BeginRequest to check for and use this cookie if all other tests (tabid, alias, domain name) fail to yield a valid portal.
Fix Tested: DNN 2.0.4
Fix Details: Make the following core changes:
1) Subhost.aspx
Add line:
Response.Cookies("portalalias").Value = DomainName
Immediately *before* line:
DomainName = ServerPath & glbDefaultPage & "?alias=" & DomainName
IMPORTANT: You will need to make this change in the "default.aspx" page of all existing child portals (since default.aspx in child portal folders is created when the portal is created by copying subhost.aspx and renaming to default.aspx)
2) Global.asax.vb (** requires recompile **)
Locate this block of code:
' TabId uniquely identifies a Portal
If PortalAlias Is Nothing Then
If TabId <> 0 Then
PortalAlias = PortalSettings.GetPortalByTab(TabId, DomainName)
End If
End If
... and change it to:
' TabId or cookie uniquely identifies a Portal
If PortalAlias Is Nothing Then
If TabId <> 0 Then
PortalAlias = PortalSettings.GetPortalByTab(TabId, DomainName)
Else
If Not (Request.Cookies("portalalias") Is Nothing) Then
PortalAlias = Request.Cookies("portalalias").Value
End If
End If
End If
3) Recompile
Side-effect: Until the user closes the browser window, any portal URL that does not contain a querystring of "tabid" or "alias" or a child portal folder in the URL will always take the user to the first child portal they accessed with their browser in that session.
Nik Kalyani
Speerio, Inc.
[DotNetNuke and ASP.Net solutions
here]