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

Tagged as

Go to top

Removing (Deleting) Querystring in ASP.NET

, 7 Apr 2011
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

GeneralMy vote of 1 PinmemberMember 1087396227-Jun-14 7:58 
GeneralMy vote of 1 PinmemberMember 1087396227-Jun-14 7:56 
QuestionQuerstring Removal PinmemberMinu H17-Mar-13 23:46 
GeneralMy vote of 5 PinmemberLechu8117-Dec-12 6:11 
QuestionMy vote of 5 PinmemberGökmen BULUT5-Jun-12 23:50 
GeneralMy vote of 5 Pinmembernarenderkumardhull29-Apr-12 20:35 
GeneralRe: > Even though the unanimous vote is that the collection shou... PinmemberAnkur\m/12-Apr-11 18:29 
GeneralRe: > OP was talking about a single request Ah, that's what's h... PinmemberJeff Bowman12-Apr-11 7:46 
> OP was talking about a single request
Ah, that's what's happened. We're talking about two different things Smile | :)
I read the thread too quickly. Based on Venkatesh's reply, I misunderstood this topic to address the problem of how to detect a page refresh and not initiate a duplicate action.
So now your technique makes sense Smile | :)

p.s. Even though the unanimous vote is that the collection should stay read-only, I think OP was pretty clever to dig in and come up with that approach. Albeit misguided, it shows initiative Wink | ;-)
GeneralRe: :D <i>I'm not seeing how you're handling state here. Each p... PinmemberAnkur\m/11-Apr-11 21:48 
GeneralRe: Oh, I doubt myself daily ;-) I'm not seeing how you're han... PinmemberJeff Bowman11-Apr-11 21:31 

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 | Mobile
Web04 | 2.8.140926.1 | Last Updated 7 Apr 2011
Article Copyright 2011 by Toniyo Jackson
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid