Bruce Chapman wrote:
Just picking up on this thread.
There's two things here.
First, if you want to know the original, requested Url (not the rewritten Url) you need to get it from the context.Items collection, like this:
string originalRequestedUrl = Context.Items["UrlRewrite:OriginalUrl"];
You should be defensive about this in case a Url Rewrite didn't happen for your request. So always check for null return values.
Next, if you want to build a Url, you should just use the NavigateUrl overloads. The mistake you're making is trying to use your existing Url to build the new one, when in fact you should be building it from the individual pieces.
So, what you should be doing is obtaining your product Id, tabid and then putting them back into the NavigateUrl() function. Ideally, within your module you should have a function which will give you back a Url for a given tab and product id - then just call this.
This would then look like :
string url = DotNetNuke.Common.Globals.NavigateUrl(tabId, "", "productId", 12); (or thereabouts, working from memory here)
This will give you back the URl as it should be for that page.
It's important to always do this and never try to construct your Urls by using find/replace or other hacking operations. The NavigateUrl function respects all of the settings within DNN surrounding Friendly Urls, which includes the correct portal alias, the current language, and anything else now or in the future. Building your own Urls outside of the DNN API is a surefire method of making sure your module will one day be 'broken' with a DNN upgrade, as happend to many people in 4.8 when the 'humanFriendly' function was switched on by default.
I was about
to abandon my project because I was not been able to find a solution for my problem
but I just realized that you replied to my message some days ago. The only
problem is that you show the way to get the URL if we know the parameters but
how can I get the URL when I do not know the parameters of another module. If
another module has added some values in the URL I will not be able to know what
the parameters are so I suppose that I have to find a way to include these
values in the NavigateUrl function. Is there an easy way to do it?