function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BBeairdBBeaird 

Stop PageReference from clearing query string in the browser URL

Is there any way to stop the default behavior of clearing out query string variables from the URL when using a PageReference with redirect set to false?

 

I have a page that renders different links depending on a "country" variable.  The Australia URL looks something like:

 

http://mydomain/tools/mytool?country=au

 

There is a form on that page, and on submit, you are redirected to the "mytool2" page which uses the same controller.  Since the PageReference redirect is set to false, this is not a client-side redirect.  However, for whatever reason, when the redirect happens, my browser's URL suddenly has the country query string truncated and becomes http://mydomain/tools/mytool.

 

While this doesn't affect any functionality, the problem is that this could confuse my Australian customers if they ever try and bookmark the post-submitted page URL that is missing the correct query string.  And if they hit the site without ?country=au, they will end up with incorrect links for their locale.

 

Why is Salesforce deleting my query string at all?  Is there any way to avoid this from happening?

 

Here is a simplified version of what the code looks like:

 

"mytool" (Page 1 with form)

<apex:page showheader="false" sidebar="false" controller="myController">
<apex:form >
<apex:pageblock title="Choose from the following options"
			mode="maindetail">
  **Various form input fields**
  <apex:commandbutton value="Submit" action="{!Submit}" />
</apex:pageblock>
</apex:page>

 


"mytool2" (Page 2)

 

<apex:page sidebar="false" standardstylesheets="false" cache="false"
	showHeader="false" controller="myController">

**Various outpanels displayed depending on what was selected from the first page**

</apex:page>

 


 

"myController" (Controller used by both pages)

public with sharing class myController{
  public PageReference submit(){
    return Page.mytool2;
  }
}