public string SetFilterBySessionKey(string controlName, string filter) { RemoveFilter(controlName); var sessionKey = Guid.NewGuid().ToString(); // note: возмножно вместо удаления параметров нужно использовать сессию while (ControlFilterParameters.Count > 2) { ControlFilterParameters.RemoveAt(0); } if (!string.IsNullOrEmpty(sessionKey) && HttpContext.Current != null && HttpContext.Current.Session != null) { HttpContext.Current.Session[sessionKey] = filter; ControlFilterParameters.Add(new FilterParameter { Key = controlName, SessionKey = sessionKey }); } else { ControlFilterParameters.Add(new FilterParameter { Key = controlName, Value = filter }); } return(sessionKey); }
public void SetFilter(string controlName, string filter) { var sessionKey = RemoveFilterGetSession(controlName); while (ControlFilterParameters.Count > 4) { ControlFilterParameters.RemoveAt(0); } if (filter != null && filter.Length > 100 && string.IsNullOrEmpty(sessionKey) && HttpContext.Current != null && HttpContext.Current.Session != null) { sessionKey = Guid.NewGuid().ToString(); } if (!string.IsNullOrEmpty(sessionKey) && !string.IsNullOrEmpty(filter) && HttpContext.Current != null && HttpContext.Current.Session != null) { if (HttpContext.Current.Session[sessionKey] != null && (string)HttpContext.Current.Session[sessionKey] != filter) { sessionKey = Guid.NewGuid().ToString(); } HttpContext.Current.Session[sessionKey] = filter; ControlFilterParameters.Add(new FilterParameter { Key = controlName, SessionKey = sessionKey }); } else { ControlFilterParameters.Add(new FilterParameter { Key = controlName, Value = filter }); } }