Search code examples
c#asp.netdotnetnuke

How to get full url from dotnetnuke


If I use this:

Request.Url.AbsoluteUri

I get full url like:

http://localhost/mysite/Default.aspx?TabID=269&OTHER-parameters

But I don't want this thing with TabID I need friendly url so if I use:

DotNetNuke.Entities.Tabs.TabController.CurrentPage.FullUrl;

I get

http://localhost/mysite/something/en-us/generatethings.aspx

But with this I don't get parameters :(
How to get full friendly complete url from dnn with all parameters?


Solution

  • Unfortunately, there isn't an easy way to get the current URL within DNN, because the URL gets rewritten before it gets to your module.

    What we'll typically do is regenerate the URL, using Globals.NavigateURL. You can use DotNetNuke.Common.Utilities.UrlUtils.GetQSParamsForNavigateURL to get all of the query string parameters from the current URL.

    So, you'd end up with something like this:

    var currentUrl = Globals.NavigateURL(
        this.TabId, 
        this.Request.QueryString["ctl"], 
        UrlUtils.GetQSParamsForNavigateURL());