Showing posts with label Querystring. Show all posts
Showing posts with label Querystring. Show all posts

Thursday, February 16, 2012

Removing some querystring values from collection

Below code is used for removing the query string parameters from the collection of parameters-

Dim isreadonly As PropertyInfo = GetType(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance Or BindingFlags.NonPublic)

' make collection editable
isreadonly.SetValue(HttpContext.Current.Request.QueryString, False, Nothing)

' remove
HttpContext.Current.Request.QueryString.Remove("uid")
HttpContext.Current.Request.QueryString.Remove("pwd")

HttpContext.Current.Response.Redirect(HttpContext.Current.Request.Url.AbsolutePath + "?" & Convert.ToString(HttpContext.Current.Request.QueryString))Rem