Click here to Skip to main content
13,351,465 members (46,116 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


10 bookmarked
Posted 7 Apr 2011

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

You may also be interested in...

Comments and Discussions

Questionthanks Pin
Member 426894718-Oct-16 1:41
memberMember 426894718-Oct-16 1:41 
QuestionThank you Pin
Member 1235752428-Feb-16 10:28
memberMember 1235752428-Feb-16 10:28 
GeneralMy vote of 1 Pin
Member 1087396227-Jun-14 8:58
memberMember 1087396227-Jun-14 8:58 
GeneralMy vote of 1 Pin
Member 1087396227-Jun-14 8:56
memberMember 1087396227-Jun-14 8:56 
QuestionQuerstring Removal Pin
Minu H18-Mar-13 0:46
memberMinu H18-Mar-13 0:46 
GeneralMy vote of 5 Pin
Lechu8117-Dec-12 7:11
memberLechu8117-Dec-12 7:11 
QuestionMy vote of 5 Pin
Gökmen BULUT6-Jun-12 0:50
memberGökmen BULUT6-Jun-12 0:50 
GeneralMy vote of 5 Pin
narenderkumardhull29-Apr-12 21:35
membernarenderkumardhull29-Apr-12 21:35 
GeneralRe: > Even though the unanimous vote is that the collection shou... Pin
Ankur\m/12-Apr-11 19:29
memberAnkur\m/12-Apr-11 19:29 
GeneralRe: > OP was talking about a single request Ah, that's what's h... Pin
Jeff Bowman12-Apr-11 8:46
memberJeff Bowman12-Apr-11 8:46 
GeneralRe: :D <i>I'm not seeing how you're handling state here. Each p... Pin
Ankur\m/11-Apr-11 22:48
memberAnkur\m/11-Apr-11 22:48 
GeneralRe: Oh, I doubt myself daily ;-) I'm not seeing how you're han... Pin
Jeff Bowman11-Apr-11 22:31
memberJeff Bowman11-Apr-11 22:31 
GeneralRe: Thanks for waiting. Let me tell this once again - Changing ... Pin
Ankur\m/11-Apr-11 22:06
memberAnkur\m/11-Apr-11 22:06 
GeneralRe: That'll be great, thanks, when you have time. I'd like to se... Pin
Jeff Bowman11-Apr-11 21:05
memberJeff Bowman11-Apr-11 21:05 
GeneralRe: No I do not, but if you need I can write it for you. It is j... Pin
Ankur\m/11-Apr-11 19:19
memberAnkur\m/11-Apr-11 19:19 
GeneralRe: :thumbsup: Thank you. :) Pin
Toniyo Jackson8-Apr-11 1:29
memberToniyo Jackson8-Apr-11 1:29 
GeneralRe: That's the spirit! :thumbsup: Cheers! Pin
Ankur\m/8-Apr-11 1:27
memberAnkur\m/8-Apr-11 1:27 
GeneralRe: Anyway, my first Tip/Trick got failure. Will do best next ti... Pin
Toniyo Jackson8-Apr-11 1:16
memberToniyo Jackson8-Apr-11 1:16 
GeneralRe: No problem Ankur. You are correct. One day i was trying to d... Pin
Toniyo Jackson8-Apr-11 1:10
memberToniyo Jackson8-Apr-11 1:10 
GeneralRe: As I said, it is kept readonly for a reason, do not change t... Pin
Ankur\m/8-Apr-11 1:00
memberAnkur\m/8-Apr-11 1:00 
GeneralReason for my vote of 5 very good.. I was looking for this s... Pin
mvamsianil5-Aug-11 0:04
membermvamsianil5-Aug-11 0:04 
GeneralRe: Thanks :) Pin
Toniyo Jackson5-Aug-11 0:30
memberToniyo Jackson5-Aug-11 0:30 
GeneralNo problem Ankur. You are correct. One day i was trying to d... Pin
Toniyo Jackson8-Apr-11 1:09
memberToniyo Jackson8-Apr-11 1:09 
GeneralWhy would anyone do this? If something is made Readonly, it'... Pin
Ankur\m/8-Apr-11 0:49
memberAnkur\m/8-Apr-11 0:49 
GeneralRe: Still, its not bad to know how to delete querystring yes? :) Pin
Toniyo Jackson8-Apr-11 0:53
memberToniyo Jackson8-Apr-11 0:53 

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

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

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