Click here to Skip to main content
Click here to Skip to main content

Tagged as

Removing (Deleting) Querystring in ASP.NET

, 7 Apr 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Removing (Deleting) Querystring in ASP.NET

We cannot delete a query string directly like below:


If you do this, you will get an error - collection is read-only. So, we need to write the below code before deleting the query string.

In C#:

PropertyInfo isreadonly = 
  "IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
// make collection editable
isreadonly.SetValue(this.Request.QueryString, false, null);
// remove


Dim isreadonly As PropertyInfo = _
  "IsReadOnly", BindingFlags.Instance Or BindingFlags.NonPublic)
' make collection editable
isreadonly.SetValue(Me.Request.QueryString, False, Nothing)
' remove
I hope that this will help you guys.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Toniyo Jackson
Software Developer
India India
No Biography provided

Comments and Discussions

GeneralRe: Thanks for waiting. Let me tell this once again - Changing ... PinmemberAnkur\m/11-Apr-11 22:06 
GeneralRe: That'll be great, thanks, when you have time. I'd like to se... PinmemberJeff Bowman11-Apr-11 21:05 
GeneralRe: No I do not, but if you need I can write it for you. It is j... PinmemberAnkur\m/11-Apr-11 19:19 
GeneralRe: :thumbsup: Thank you. :) PinmemberToniyo Jackson8-Apr-11 1:29 
GeneralRe: That's the spirit! :thumbsup: Cheers! PinmemberAnkur\m/8-Apr-11 1:27 
GeneralRe: Anyway, my first Tip/Trick got failure. Will do best next ti... PinmemberToniyo Jackson8-Apr-11 1:16 
GeneralRe: No problem Ankur. You are correct. One day i was trying to d... PinmemberToniyo Jackson8-Apr-11 1:10 
GeneralRe: As I said, it is kept readonly for a reason, do not change t... PinmemberAnkur\m/8-Apr-11 1:00 
GeneralReason for my vote of 5 very good.. I was looking for this s... Pinmembermvamsianil5-Aug-11 0:04 
GeneralRe: Thanks :) PinmemberToniyo Jackson5-Aug-11 0:30 
GeneralNo problem Ankur. You are correct. One day i was trying to d... PinmemberToniyo Jackson8-Apr-11 1:09 
GeneralWhy would anyone do this? If something is made Readonly, it'... PinmemberAnkur\m/8-Apr-11 0:49 
GeneralRe: Still, its not bad to know how to delete querystring yes? :) PinmemberToniyo Jackson8-Apr-11 0:53 
GeneralRe: Hi Ankur, do you have a small snippet handy? Thanks. PinmemberJeff Bowman11-Apr-11 16:00 
GeneralI don't see any value in this Tip/Trick. I have read the rep... PinmemberVenkatesh Mookkan7-Apr-11 7:57 
GeneralRe: No problem Venky. I thought it will useful for somebody. My... PinmemberToniyo Jackson8-Apr-11 1:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141220.1 | Last Updated 7 Apr 2011
Article Copyright 2011 by Toniyo Jackson
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid