Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Problems with querystrings



How can I build a correct link that includes querystring parameters? and how can I get the querystring parameters on the receiving page.

I have a

PageData page;

And try to change LinkUrl for that page like this:

page.LinkURL = UriSupport.AddQueryString(page.LinkURL, "?docid=", DocumentId)

and then I use Request.QueryString["docid"] 

but I only get the querystring  {&id=13515&epslanguage=sv} 

Thanks for your help.
Mar 14, 2012 13:55


page.LinkURL already contains parameters (id, epslanguage and so on). So you cant pass ?-sign in the parametername. This should be correct:

string url = UriSupport.AddQueryString(page.LinkURL, "docid", DocumentId);

Which would result in /Templates/Page.aspx?id=13515&epslanguage=sv&docid=12345

Why do you set the page.LinkURL?

Mar 14, 2012 14:57

You could also do this directly in you template (aspx-file).

<%= CurrentPage.LinkURL + "&docid=" + DocumentId %>


Mar 14, 2012 14:59


I doesn't work. I use a PageList and for every page I create in that list I show the same page but with different content that’s why I need to change the LinkURL.

Here is the code

//delete pages before create new
 DataFactory.Instance.DeleteChildren(rightMenu.PageListRoot, false, AccessLevel.Delete);

foreach (DocumentList docList in medicalSourceDocumentsList)
     pagelink = DataFactory.Instance.GetDefaultPageData(rightMenu.PageListRoot, 44);
     clonelink = pagelink.CreateWritableClone();
     clonelink.PageName = docList.DocumentTitle;                                   

     clonelink.Property["Title"].Value = pageListControl.CurrentPage.Property["Title"].Value;
    clonelink.Property["RootPage"].Value = pageListControl.CurrentPage.Property["RootPage"].Value;                
  //Build querystring
  clonelink.LinkURL = UriSupport.AddQueryString(clonelinkSeeAlso.LinkURL, "docid=", docList.DocumentId);                    
   DataFactory.Instance.Save(clonelink, SaveAction.Publish, AccessLevel.Read);

               pageListControl.DataSource = linkDataCollection;


Mar 15, 2012 8:53

Ok. Deleting and saving pages is kinda time consuming, so it's not recommended to do that on every rendering.

I'm not sure you can save a page with another LinkURL. And in your code I don't think the LinkURL is generated yet, because it needs a roundtrip to the database to get an id to the page.

I would recommend using my other solution, adding the docid on rendering in the pagelist instead. You can store the docid in a property on the page.

<%# Container.CurrentPage.LinkURL + "&docid=" + Container.CurrentPage["DocumentID"] %>



Edited, Mar 15, 2012 9:04

You can also set an external link on the page.


cloneLink.LinkType = PageShortcutType.External;
cloneLink["PageExternalURL"] = UriSupport.AddQueryString(clonelinkSeeAlso.LinkURL, "docid", docList.DocumentId);

PageExternalURL is a built-in property that you find on the 'Category' tab in edit mode.   And you should not have a ? or = in your queryparameter name.

Mar 15, 2012 9:12

Thanks for your help, I will try this.

Mar 16, 2012 7:47

Did this solve your problem Margareta?

Mar 27, 2012 13:32

Yes i solved it by using querystrings and change the view depending on the id instead of creating pages.

Mar 28, 2012 7:42
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.