how to clear the querystring values after retrieving?

Posted by Prabu_Spark under ASP.NET on 12/27/2012 | Points: 10 | Views : 25627 | Status : [Member] | Replies : 5
Hi sir,
Tell me the steps to clear the querystring values after retrieving the values.
Kindly give me the solution for this problem.

With regards,
J.Prabu.
[Email:prbspark@gmail.com]



Responses

Posted by: Pavanandey on: 12/27/2012 [Member] Bronze | Points: 25

Up
0
Down
Request.QueryString.Clear();

Thanks
Pavan Kumar
Mark Answer if this fits the need

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 12/27/2012 [Member] Bronze | Points: 25

Up
0
Down
you can also redirect the page to a url with no query string values

Thanks
Pavan Kumar
Mark Answer if this fits the need

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Guna27 on: 12/27/2012 [Member] Starter | Points: 25

Up
0
Down
The QueryString values are read only you can't clear the values, so have redirect to same page to clear the values.

Guna..............

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saratvaddilli on: 12/28/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi prabhu,

You can yous namevalueCollection in asp.net

Just create an object on namevalueCollection which contains a query string and now object.remove("What ever values you want");


Thanks and Regards
V.SaratChand
Show difficulties that how difficult you are

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Singhrt275 on: 2/18/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Prabhu

As Saratchand suggest, that's the only option you can use to clear Query String Parameters. See Below

// Get the NameValueCollection
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("YourQueryStringParameter");

Don't forget to add following Using Statement

using System.Collections;
using System.Reflection;

I know you asked this question in December Last year and by now you may have solved the issue, but this will be helpful for other users.

Thanks
Happy Coding
Raj

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response