Sep 11 2007
DotNetNuke: Redirect after Login
I was doing some coding on a DotNetNuke module today and ran into a problem where I needed to check to see if a user was authenticated when they arrived at my page. If they weren’t I wanted to be able to send them to the login screen and allow them to login. Once they’d logged in, I wanted them to redirect back to the url that they were previously trying to get to.
I couldn’t actually find a reference to this anywhere so I thought I’d post the code up that allowed me to do it.
If Not Request.IsAuthenticated Then Response.Redirect(Globals.NavigateURL(PortalSettings.LoginTabId, True, PortalSettings, "Login", "returnurl=" & Server.UrlEncode(Request.Url.ToString))) End If
Because the login page accepts a returnurl parameter in the querystring I can pass the current url of the page I’m on to the login page and it will return to that page after the user is logged in.
