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 18:33pm
Edited 5-Jan-12 3: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 375
1 Afzaal Ahmad Zeeshan 125
2 Zoltán Zörgő 120
3 DamithSL 100
4 Peter Leow 95
0 enhzflep 40
1 Richard Deeming 25
2 OriginalGriff 10
3 Anddos 10
4 Kornfeld Eliyahu Peter 10


Advertise | Privacy | Mobile
Web01 | 2.8.150224.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2015
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