Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi,
 
How to Clear the Query String value.
 
Example:
response.write("sample.aspx?id=3")
 
iam getting this value another page like
 
int id=request.querystring["id"];
 
I want to clear this value in update method.
 
iam using followings
 
Response.ClearContent();
Request.QueryString.Remove("id");  
but it is not clears
 
Thanks®ards
venkat
Posted 4-Jan-12 17:33pm
Edited 5-Jan-12 2:20am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

To clear all querystrings, you can invoke the Request.QueryString.Clear();
which will remove all the querystrings at the url
To remove a specific querystring invoke Request.QueryString.Remove("name of the querystring"),
 
example:
 
http://www.mypage.aspx?id=123
 
Request.QueryString.Remove("id");
or you can use
 
Request.QueryString.Clear();
which will remove or the querystrings
 
example
 
http://www.mypage.aspx?id=123&date=29/8/2008
 
Request.QueryString.Clear();
result
Url without the two querystrings (id,date);
  Permalink  
v2
Comments
emad_hawaree at 4-Jan-12 23:48pm
   
ALSO TRY TO POST IF YOU WANT TO HIDE
zadeabhi at 26-Feb-13 2:29am
   
Request.QueryString.Clear();
won't work as "QueryString" collection is read only, you can't use that directly it will throw exception as "Collection is read-only".
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
                // make collection editable
                isreadonly.SetValue(this.Request.QueryString, false, null);
                // remove
                this.Request.QueryString.Remove("id");
 

Hi solved this using the above code
  Permalink  
v2
Comments
Rajesh Puli at 5-Jan-12 8:21am
   
You are not supposed to post here
murali21oct at 17-Jul-13 10:03am
   
Worked for me. Thanks!
Imadoddin at 3-Feb-14 6:33am
   
PropertyInfo doesnot contain method SetVAlues
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

you can use
 
Request.QueryString.Clear();
for clear all the query string
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

I have one requirement like this
I have a table CUSTOMER in that CUSTID,NAME,URL columns is thier
CUSTID NAME URL
1 asp www.asp.net
2 weblog www.weblogs.asp.net
3 google www.google.com
 
My question is I opening perticular url based on CUSTID
 
I am Passing parameter Like www.Example.com?CUSTID=1 That
 
corressponding URL data(Ex:www.asp.net) It will open directly in browser
 
using asp.net........
plz help me ...........
Thank you,
anil
  Permalink  
Comments
Anand Madeswaran at 13-Dec-12 7:14am
   
clear the query string value

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

  Print Answers RSS
0 OriginalGriff 328
1 Sergey Alexandrovich Kryukov 295
2 Gihan Liyanage 292
3 ClimerChinna 222
4 Abhinav S 187
0 Sergey Alexandrovich Kryukov 8,213
1 OriginalGriff 7,089
2 CPallini 2,598
3 Richard MacCutchan 1,925
4 Abhinav S 1,778


Advertise | Privacy | Mobile
Web02 | 2.8.140826.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100