Remove Querystring item in ASP.NET

If we try to remove/delete a query string directly using below code, we will get an error - collection is read-only.


In order to solve above error problem, we need to write below code before we remove them.

// reflect to readonly property
PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);

// make collection editable
isreadonly.SetValue(this.Request.QueryString, false, null);

// remove


  1. Thanks for the post, very helpful!

    Just one thing, you're missing a left parenthesis after "typeof".

  2. I am glad it helped you.
    Thanks for the catch. I have corrected it.

  3. It is really a great work and the way in which u r sharing the knowledge is excellent.
    Thanks for helping me to understand basic concepts. As a beginner in dot net programming your post help me a lot.Thanks for your informative article.Dot Net training in chennai | Dot Net training institutes in chennai | Dot Net training in velachery

  4. it’s really nice and meanful. it’s really Good blog.

    Dot Net Online Training Hyderabad

  5. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.
    or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.

  6. Excellent and very cool idea and the subject at the top of magnificence and I am happy to this post. Interesting post! Thanks for writing it. Great job..Keep update more article..
    .Net Certification Training Gurgaon