public static IDictionary<string, object> getLinkParams(HttpRequestBase httpRequest, params string[] ignoreKeys)
{
IList<string> incomingParams = httpRequest.QueryString.AllKeys.Union(httpRequest.Form.AllKeys).ToList();
IDictionary<string, object> linkParams = new Dictionary<string, object>(incomingParams.Count);
foreach (string key in incomingParams)
{
// X-Requested-With is appended for AJAX calls.
if (key != null && key != "X-Requested-With" && !ignoreKeys.Contains(key, StringComparer.OrdinalIgnoreCase))
{
string value = httpRequest.QueryString.AllKeys.Contains(key) ? httpRequest.QueryString[key] : httpRequest.Form[key];
if (!String.IsNullOrWhiteSpace(value))
{
if (linkParams.ContainsKey(key))
{
linkParams[key] = value;
}
else
{
linkParams.Add(key, value);
}
}
}
}
return linkParams;
}