Server.Transfer call with query string calls current page instead of the given page
<p>I didn't have much luck finding out much about this one…</p>

<p>I have an ASP page that is called from code somewhere else with a query string:</p>

<pre><code>[domainpath]/FulfilmentReceipt.aspx?fulfilmentId=226F7486-3D30-439D-92BB-94972234A809
</code></pre>

<p>In the <code>Page_Load</code> there's a <code>Server.Transfer</code> call that should move the response execution to another page with a different query string (the <code>Format()</code> below appears to work fine BTW):</p>

<pre><code>Server.Transfer(String.Format("confirmationReceipt.aspx?bId={0}&amp;f={1}&amp;print=true", basketId, franchiseeId)))
</code></pre>

<p>The bit I don't understand comes next. The transfer call appears to get routed back to <em>FulfilmentReceipt.aspx</em>, the first page, but with the new query string. This then causes an error as the <code>fulfilmentId</code> part of the query string is now missing. Why does this not call into <code>confirmationReceipt</code> as expected?</p>

<p>I can confirm that <code>confirmationReceipt</code> page is never called by debugging into the process and that <code>fulfilmentReceipt</code> is loaded twice. There is no code at all in the <em>Global.asax</em> file so no routing there and the <code>confirmationReceipt</code> page itself has no <code>Redirect</code> or <code>Transfer</code> calls and is pretty simple.</p>

<p>Additionally the error page rendered in the browser's address bar shows the new query string but as part of the orginal URL. I had thought that the URL seen should not alter as a result of <code>Server.Transfer</code>.</p>

<p>Any ideas?</p>

<p>Many thanks.</p>

<p><strong>UPDATE</strong></p>

<p>I haven't made any real progress but following Richthofen's advice gave a result of sorts. Using <code>Response.Redirect</code> instead of <code>Server.Transfer</code> DOES give the desired result when the call is from a browser. But the call is made by a third party library that cannot handle the redirect response.</p>

<p>Trying <code>Server.Transfer</code> with the <code>preserveForm</code> option makes no difference. To clarify, the transfer ends up calling <code>FulfilmentReceipt.aspx?bId={0}&amp;f={1}&amp;print=true</code>. Wrong page, right query string.</p>

<p><strong>MORE UPDATE</strong></p>

<p>I have solved my problem by refactoring the <code>confirmationReceipt</code> page to accept the query string passed to <code>fulfilmentReceipt</code> and changing the <code>Server.Transfer</code> call to simply transfer to <code>confirmationReceipt</code> without specifying a query string. The transfer than goes to the right place with the original query string.</p>

<p>The question still stands though out of curiosity. Is it simply that <code>Server.Transfer</code> cannot deal with urls containing query strings correctly?</p>
