Request.Querystring handling without name/value pairs

G

Guest

I am working with an old web application writing new ASP.NET code to replace
functions previously handled by a monolithic ISAPI dll and intercepting some
calls to it. It uses, however, a query string made up of isolated values
(i.e. <value>&<value>& . . .) rather than <name>=<value> pairs.

I have figured out how to get the entire string in order to parse it, but I
have not yet figured out an easy way (easier, that is, than letting it throw
an exception and handling it) to check to make sure the string is not null.

Can anyone point me in the right direction for how best to do this?

Also, if anyone can suggest an easier way to obtain the values than getting
the whole string and parsing it 'manually' that would be helpful, too.

I know this ought to be quite simple once one knows how, but I have been
having a very hard time finding information on how to do it. Everything I
have found concerning Request.QueryString seems to take it for granted that
all query strings are going to be formated as name/value pairs rather than as
an ordered string of values.

Thanks!

All the best,

will
 
G

Guest

Peter,

Thanks much for trying to help. Yes, the query string does use the &
character as a delimiter between values. I guess I was not as clear as I
might have been. I am not having any problem getting the entire query
string. I am able to do that by simply using a zero index as follows:

string s = Request.QueryString[0];

I can then 'manually' parse the string without too much difficulty (although
it would be nice to have an easier way to do it.

My main problem, though, is that the above code fails (i.e. generates an
exception) if there is no query string at all. If the query string were
organized as name/value pairs, I could test for != null for a specific named
parameter before trying to read it. What I am looking for, though, is a way
to test to see if there is anything there at all.

I have tried checking (I think) to see if (Request.QueryString[0] != null)
but (unless I mis-remember what happened) that also throws an exception when
the CLR tries to resolve "Request.QueryString[0] prior to making the
comparison. So that doesn't work.

Obviously, I could just put the thing in a try block and intercept the
exception, but I have a hard time believing there isn't a simpler way to do
it. That is the key info I am seeking (i.e. how to do that).

The thought has occurred to me that maybe I need to move up the inheritance
heirarchy to, say, the HttpRequest class, prior to whatever builds the
name/value pair collection, but I am not very familiar with the details of
how all that works, so I figured I would ask here before spending a lot more
time combing through the documentation to try to figure out if I could do it
that way.

Anyway, I do very much appreciate your getting back to me!

All the best,

will


--
William F. Zachmann
Canopus Research Inc.
http://www.canopusresearch.com
 

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

Members online

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top