Clear QueryString on PostBack?

R

Raterus

Howdy,

Simple question, but I can't figure out how to do it. I have a a page which is called initially with a querystring. After I get the querystring values, I don't need the querystring to appear in the url anymore. How can I get rid of it? A postback doesn't clear it, it just keeps tagging along. I tried Request.QueryString.Clear, but get "readonly" errors.

I want to do this, because eventually I use server.transfer within this page, and the querystring, tags along to new page as well, even after a postback on this new page. I start to get problems when, from second page, I perform a server.transfer back to the first page. My problems are explainable, if the querystring was empty, the page would work properly, but since the querystring is set, my page essentially breaks. I'm not too concerned about this, because if I could get rid of the querystring, I wouldn't have this problem!

Thanks for any help on this,
--Michael
 
N

Nicole Calinoiu

Michael,

The Server.Transfer method has an overload that allows you to specify
whether the querystring and form data should be preserved or not. Using
this appropriately should give the result you desire. Otherwise, might a
client-side redirection work for at least one of your two transfers?

HTH,
Nicole


Howdy,

Simple question, but I can't figure out how to do it. I have a a page which
is called initially with a querystring. After I get the querystring values,
I don't need the querystring to appear in the url anymore. How can I get
rid of it? A postback doesn't clear it, it just keeps tagging along. I
tried Request.QueryString.Clear, but get "readonly" errors.

I want to do this, because eventually I use server.transfer within this
page, and the querystring, tags along to new page as well, even after a
postback on this new page. I start to get problems when, from second page,
I perform a server.transfer back to the first page. My problems are
explainable, if the querystring was empty, the page would work properly, but
since the querystring is set, my page essentially breaks. I'm not too
concerned about this, because if I could get rid of the querystring, I
wouldn't have this problem!

Thanks for any help on this,
--Michael
 
R

Raterus

Never knew it had that option, but unfortunately that doesn't help, as the default is "false".
I think my more explain my problem now by this example, take server.transfer out of it. After my page that uses the querystring is rendered, this appears in the html source. The postback uses the querystring, I don't want it to.

<form name="Form1" method="post" action="manage.aspx?docID=40" id="Form1">
I want it to say this
<form name="Form1" method="post" action="manage.aspx" id="Form1">

Any ideas how I can clear the querystring from being rendered like this?

--Michael
 
B

bruce barker

the only way to clear the querystring is a redirect. the browser does not
know you do a server transfer, it just remembers what the url (including
query string) was for the postback. to clear it you send the browser a
redirect, so that the new rendered page matchs the new url.

-- bruce (sqlwork.com)


Howdy,

Simple question, but I can't figure out how to do it. I have a a page which
is called initially with a querystring. After I get the querystring values,
I don't need the querystring to appear in the url anymore. How can I get
rid of it? A postback doesn't clear it, it just keeps tagging along. I
tried Request.QueryString.Clear, but get "readonly" errors.

I want to do this, because eventually I use server.transfer within this
page, and the querystring, tags along to new page as well, even after a
postback on this new page. I start to get problems when, from second page,
I perform a server.transfer back to the first page. My problems are
explainable, if the querystring was empty, the page would work properly, but
since the querystring is set, my page essentially breaks. I'm not too
concerned about this, because if I could get rid of the querystring, I
wouldn't have this problem!

Thanks for any help on this,
--Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top