Working with URL Parameters using Page Parameters
The following code will use a value from the url querystring. There are various ways to pick it up, but we recommend the cross-platform API which works in Dnn and Oqtane.
-
Cross-Platform (Dnn and Oqtane):
@CmsContext.Page.Parameters["id"]
-
This would only work in Dnn:
@Request.QueryString["id"]
Usually you would have somepagename?id=27
in the url, and then using @CmsContext.Page.Parameters["id"]
you would pick it up.
But with DNN, there is an additional processing that happens, as DNN tries to create nice URLs resulting in somepagename/id/27
. But on the server, this is still treated as the ?id=27
, so you still use the same method to access it.
Test changing this page URL
Below you'll find some links which change the url, so you can see how the output changes: