Removing a Request variable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I set ndi in a repost of a page:

window.location.href=
'../Test/test.aspx' +
'?ndi=' +
theform.domain_SELECT.options.selectedIndex;

In the test.aspx.cs code-behind, I test if ndi is set as

if ( Request [ "ndi" ] != null )

How can I cause ndi to become null once that I've tested it and found it
existed? A Session variable is cleared by Session.Contents.Remove. Is there
an equivalent for a Request variable?

TIA
 
Hi Gus,

I think the querystring name value collection of the HttpRequest object
is read only.

I'm a little puzzled why you might need this functionality? When needing
a querystring value, you might want to use a variable, especially as the
ndi variable is actually an integer.

int ndi = -1; //no ndi value selected

if (Request["ndi"] != null && Request["ndi"] != String.Empty)
{
ndi = Int32.Parse(Request["ndi"]);
}


if (ndi > -1)
{
Debug.WriteLine("We have a ndi value!");
}

Ward
 
Ward, of course you are right in your questioning motive. Last night I
realized that the only time I needed to test ndi was in the case ! PostBack.
That saves trying to clear a read-only variable.

Thanks for reminding me about the String.Empty test.

Thanks for your thoughts.

--
Gus Gustafson


wbekker said:
Hi Gus,

I think the querystring name value collection of the HttpRequest object
is read only.

I'm a little puzzled why you might need this functionality? When needing
a querystring value, you might want to use a variable, especially as the
ndi variable is actually an integer.

int ndi = -1; //no ndi value selected

if (Request["ndi"] != null && Request["ndi"] != String.Empty)
{
ndi = Int32.Parse(Request["ndi"]);
}


if (ndi > -1)
{
Debug.WriteLine("We have a ndi value!");
}

Ward

Gus said:
I set ndi in a repost of a page:

window.location.href=
'../Test/test.aspx' +
'?ndi=' +
theform.domain_SELECT.options.selectedIndex;

In the test.aspx.cs code-behind, I test if ndi is set as

if ( Request [ "ndi" ] != null )

How can I cause ndi to become null once that I've tested it and found it
existed? A Session variable is cleared by Session.Contents.Remove. Is there
an equivalent for a Request variable?

TIA
 
Back
Top