CTCClassSchedule.Common.Helpers.getLinkParams C# (CSharp) Method

getLinkParams() public static method

Gets the current http get/post params and assigns them to an IDictionary This is mainly used to set a Viewbag variable so these can be passed into action links in the views.
public static getLinkParams ( System.Web.HttpRequestBase httpRequest ) : object>.IDictionary
httpRequest System.Web.HttpRequestBase
return object>.IDictionary
        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;
        }