0
votes

I'm creating a custom HttpModule for DNN 6/7 to do a little user tracking on our sites. I've setup the HttpModule to log the Referral Url and the Current Page Url. I'd also like to have the HttpModule website platform inspecific so it works with a DNN site and non-DNN sites.

t.Referrer = request.UrlReferrer != null ? request.UrlReferrer.ToString() : "(direct / unknown)";
t.Page = request.Url.ToString();

The referral URL presents as I intend (http:// site / folder / page.aspx), but the current page is presenting as the DNN tab (http:// site / folder / default.aspx?TabID=123).

Is there a way in my custom module to access the "DotNetNuke.Entities.Tabs.TabController.CurrentPage.FullUrl" ?

I guess, furthermore, also how to elegantly access FullUrl if it's available (when/if the HttpModule is used with a DNN site and/or page) and simply accessing the URL normally (when/if the HttpModule is NOT used with DNN)?

I think obviously that would just be an If/Null/Else, but is there a more elegant way to handle that in this situation?

C# example would be best, but I understand the VB syntax as well.

Thanks!

2
I have used the TabController to access the current page in a module before, did you try that?box86rowh

2 Answers

2
votes

The URL changes to friendly after your module gets loaded. You should be able to do something like this though to get the DNN page URL.

string currentURL = Globals.NavigateURL(PortalSettings.ActiveTab.TabID);

0
votes

Per Austin Wernli's suggestion, I ended up doing this:

protected string GetPageUrl(string TabIdUrl)
    {
        if (TabIdUrl.Contains("TabID"))
        {
            try
            {
                Uri uri = new Uri(TabIdUrl);
                string param = HttpUtility.ParseQueryString(uri.Query).Get("TabID");
                int tabid = Convert.ToInt32(param);
                return Globals.NavigateURL(tabid);
            }
            catch(Exception ex)
            {
                return TabIdUrl + "| ERROR: " + ex.ToString().Take(200);
            }
        }
        else
            return TabIdUrl;
    }