473,383 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Removing Items From QueryString

A.M
Hi,

When I call
Request.QueryString.Clear();

ASP.NET throws me this exception:

Exception Details: System.NotSupportedException: Collection is read-only

If the collection is read-onle, then why there is a Clear() method?

If I can not call Clear() methid in certain phases of QueryString's life
time, then how can I remove items from QueryString during postbacks?

Thanks,
Alan
Nov 18 '05 #1
6 7790
The collection is readonly which means you can't modify it. Not at all - not
directly or indirectly.

The querystring can't be controlled from within the code, because by the
time your code fired it is already passed to you. This makes perfect sense
if you think about it <g>...

I'm guessing you want to modify the URL of the page? The only way to do this
is to Redirect to another page or possibly using some client script to
modify the Location. ASP.Net always posts back to the same URL and you
cannot change that from the server side...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web
"A.M" <no*****@online.nospam> wrote in message
news:Of**************@TK2MSFTNGP11.phx.gbl...
Hi,

When I call
Request.QueryString.Clear();

ASP.NET throws me this exception:

Exception Details: System.NotSupportedException: Collection is read-only

If the collection is read-onle, then why there is a Clear() method?

If I can not call Clear() methid in certain phases of QueryString's life
time, then how can I remove items from QueryString during postbacks?

Thanks,
Alan

Nov 18 '05 #2
Hi Alan,

I think Rick has provided enough information to you. What I want to tell is
that the Clear() method is a member of NameValueCollection class, which is
for general use.(HttpRequest.QueryString property return a
NameValueCollection object). While QueryString can not be modified by you,
so the Clear method can not be used.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #3
Hi Alan,

Does our reply make sense to you? Do you still have concern on this issue?

Please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #4
A.M
Thank you Jeffrey,

That Clear method confused me. It does make sense QueryString be readonly.

However, technically, It should be quite doable to change QueryString by
*during post backs *. What do you think?


""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:aq**************@cpmsftngxa10.phx.gbl...
Hi Alan,

Does our reply make sense to you? Do you still have concern on this issue?

Please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #5
A.M

I think you missed one point,

Technically, It should be quite doable to change QueryString *during post
backs *

Is it implemented in ASP.NET?

"Rick Strahl [MVP]" <ri********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
The collection is readonly which means you can't modify it. Not at all - not directly or indirectly.

The querystring can't be controlled from within the code, because by the
time your code fired it is already passed to you. This makes perfect sense
if you think about it <g>...

I'm guessing you want to modify the URL of the page? The only way to do this is to Redirect to another page or possibly using some client script to
modify the Location. ASP.Net always posts back to the same URL and you
cannot change that from the server side...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web
"A.M" <no*****@online.nospam> wrote in message
news:Of**************@TK2MSFTNGP11.phx.gbl...
Hi,

When I call
Request.QueryString.Clear();

ASP.NET throws me this exception:

Exception Details: System.NotSupportedException: Collection is read-only

If the collection is read-onle, then why there is a Clear() method?

If I can not call Clear() methid in certain phases of QueryString's life
time, then how can I remove items from QueryString during postbacks?

Thanks,
Alan


Nov 18 '05 #6
A PostBack is simply an HTTP Request using the POST method, rather than the
GET method. The Query String is still read-only. The only way to change the
Query String is to Response.Redirect, which tells the browser to Request the
new URL you send it, with the parameters it has in it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"A.M" <no*****@online.nospam> wrote in message
news:#A**************@TK2MSFTNGP10.phx.gbl...
Thank you Jeffrey,

That Clear method confused me. It does make sense QueryString be readonly.

However, technically, It should be quite doable to change QueryString by
*during post backs *. What do you think?


""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:aq**************@cpmsftngxa10.phx.gbl...
Hi Alan,

Does our reply make sense to you? Do you still have concern on this issue?
Please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Utter Newbie | last post by:
Just wondeing if there is a way to keep from having a certain parameter sent when posting a form to another page (method=get)... So as an example a page will post something like this from a form...
0
by: scott | last post by:
Below, I'm trying to remove the querystring name& value of "catID=12". I mananged to isolate the RESULTS part, but I need to be able to strip the querystring name and it's value, no matter if the...
3
by: Jeremy Owens-Boggs | last post by:
We are trying to implement a dual list box selection where you have two list boxes, You highlight items in the right side list box, click a button and this moves those items over to the left hand...
3
by: Joey | last post by:
Hi, I'm trying to add a default item to my listbox but when I do it tells me that it's not defined, could someone tell me the syntax I need to use to get the listbox control to display a default...
7
by: Keith Patrick | last post by:
After completely giving up on finding some way in my ASP.Net app to take a query string URL and redirect to it as a POST instead, I went with a system like so: Upon "redirection," all the...
2
by: Milsnips | last post by:
hi there, i have the following HTML code: -------------------------- <asp:DropDownList id="hddList" runat="server"> <asp:ListItem Value="1">Item 1</asp:ListItem> <asp:ListItem Value="2">Item...
5
by: Phill W. | last post by:
(VB'2003) What's the correct way to remove multiple, selected items from a ListView control (say, from a ContextMenu)? I ask because I'm getting a very annoying ArgumentOutOfRangeException...
2
by: sree reddy | last post by:
..cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls;
7
by: =?Utf-8?B?Sm9lbCBNZXJr?= | last post by:
I have created a custom class with both value type members and reference type members. I then have another custom class which inherits from a generic list of my first class. This custom listneeds...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.