Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing a parameter from the querystring 1

Status
Not open for further replies.

belle9

Programmer
Nov 3, 2004
87
US
When I try to remove a parameter from the querystring, I get an error that the collection is read-only. How can I set it to allow me to update the collection? I assume it's possible since there are functions built in to do just that..

Code:
request.QueryString.Remove("ProdID")
 
why do you want to remove it? If it's a security issue, you can send along values in other ways than the query string.

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Just out of interest why do you want to remove it?

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
So what are you trying to do exactly? Items in the QueryString collection of the Request object are set by the url used to make the request, and are generally not programmatically manipulated.

I suspect you are trying to create a querystring to send parameters to a page. If so, the querystring needs to be built up manually using string concatenation or a StringBuilder. There is a great framework at the 4GuysFromRolla site that makes this super easy.


HTH



[pipe]
Share your knowledge! -
 
I'm using the querystring functionality instead of the session variable due to my not being able to figure out why the session var is not saving at the first load (see my previous post). So I'm sending the variable in the querystring. However, once I do what it is i want to with that variable, I'd like to remove it from the querystring, otherwise every time the page loads it sees that var in the querystring and goes into that logic flow..I'd like to execute that logic flow once, when it first sees prodID in the querystring, and that's it...
 
You can't remove it. The Request.Querystring collection is read-only so you can't do it like that. If it is a security issue to show it (which it sounds like) then either encrypt it or best of all don't pass them through the querystring at all.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
If you put

Code:
If Not Page.IsPostBack Then
  'check for querystring value here...
End If

it shouldn't go into the same logic every time...

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Yea, I got it working that way..

Just a question: If you can't remove it, why is there a command for Request.Querystring.Remove or .Clear?
 
I think it may have been left over from an earlier version of the framework

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Nope, never figured it out. It's been bugging me!

Using window.open will spawn another window, something I don't think people will appreciate...
 
It's worth re-installing IIS and .Net framework.
Not a visual Studio Problem.
Those two uninstall and install pretty quickly.
 
Youre saying to uninstall IIS and .Net framework from my local machine? Or from the server? I'm working off of my own machine, but when I deploy it to the server the same error happens...
 
I have had to do that to production machines before.
Try .net Framework first. IIS could take some time to reinstall all the webs again.
 
You have session state turn off in IIS on the server.
Go to iis admin.
Right click on the server node.
Goto Properties/Home Directory/Configuration/Options

You have session state disabled.
 
Good call, but no. I have enable session state clicked, timeout is 20 minutes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top