DotNetNuke NavigateURL() returns FriendlyUrls, which is not always suitable.

My DotNetNuke site  has HostSetting(“UseFriendlyUrls”) = “Y”, which is generally good.

The most popular function used in DNN to generate url is NavigateURL.
However when I want to get Page Url and then add additional query parameters, NavigateURL() is not the best choice.
NavigateURL returns FriendlyUrl, and after adding extra parameters (e.g.
http://localhost/FSDNN/vKnowledgeDataEditing/tabid/59/Default.aspx?List=SubscriptionSearchInterest ) the structure of URL becomes different to what HttpModules.UrlRewrite expects.

HttpModules.UrlRewrite replaces TabId to -1 and appropriate page is not found.

The solution is to use = ApplicationURL(Tabid)

sUrl

instead of NavigateURL and then add QueryString parameters manually.

Overloads of NavigateURL have AdditionalParameters parameter ,that probably was designed by DNN authors to add arbitrary query parameters.
It is possible to parse multiple QueryString parameters into array of string AdditionalParameters and then pass it to appropriate .Sample how to split QueryString into AdditionalParameters array of string is in DNN Default.aspx.vb InitializePage function.

Unfortunautely default FriendlyUrls implementation moves parameters into part of the path ,but default UrlRewrite HttpModule unable to restore them back.
I don’t have enough experience with Rewrite rules to fix it, so using ApplicationURL is a good alternative for me.

 

 

Advertisements