Back to all posts

DNN Navigation Redirect with Parameters and No Control

Posted on Jun 08, 2009

Posted in category:
Development
DNN

When working with DotNetNuke I often find it necessary to do a redirection back to the current page, with additional query string parameters.  Not actually switching views, but just back to the same page so that some other action could be taken for a specific module.  In the past most of the examples I found used this process.

The Old Way
DotNetNuke.Common.Globals.NavigateUrl(this.TabId) + "?mykey=myvalue"

Which would create a url such as

http://www.mysite.com/MyFolder/Default.aspx?mykey=myvalue

Although a fully functional URL that works 100%, it is not something that can be easily copied, and overall doesn't look all that fancy.  Looking through the functionality of the various NavigateUrl overloads, it didn't seem apparent that there was something that could be used to re-write that type of URL.  Well, I missed something using the following code.

The Right Way
DotNetNuke.Common.Globals.NavigateUrl(this.TabId, "", "mykey=myvalue")

From this example, we provide the tabId, a blank ControlKey, and then our added parameter value.  We could add additional parameters as well.

This results in a URL similar to the following.

http://www.mysite.com/MyFolder/mykey/myvalue/Default.aspx

Now, this is a fully re-written URL, and something much easier for a person to remember.  I hope this has been helpful!