In your 404 user page check Request.Url.Query. The request line should be in the form: 404, here the old request URL is sent.
Remove 404; part and create a new Uri object with this data. Congrats - you have access to the old URL and you can easily get query string parameters :)
For instance:
var url = new Uri(HttpUtility.UrlDecode(Request.Url.Query));
if (url.Query.Length > 0)
{
var parameters = url.Query.TrimStart('?').Split('&');
foreach(var p in parameters)
{
var parts = p.Split(new[]{'='}, 2).Dump();
var name = parts[0];
var value = parts[1];
}
}
source
share