VB.NET
Response.Redirect(Request.UrlReferrer.AbsolutePath & "?query=1")
This is a working example of how to navigate to the urlreferrer and include a new querystring.
THE PROBLEM
When urlreferrer includes an existing querystring the rendered markup becomes:
url.aspx?existing=1?query=1
The url does not resolve correctly because of the second ? which should instead be &
QUESTION
How to determine if a urlreferrer already has querystring and implement the correct code to accomodate?
SOLUTION
If (Request.UrlReferrer.OriginalString.Contains("?")) Then
Response.Redirect(Request.UrlReferrer.OriginalString & "&query=1")
Else
Response.Redirect(Request.UrlReferrer.OriginalString & "?query=1")
End If
AbsoluteUrl does not include querystrings use OrigionalString as referrer.