Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Request.Querystring handling without name/value pairs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Will Zachmann - 01 Aug 2007 18:46 GMT
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

Signature

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

Peter Bromberg [C# MVP] - 01 Aug 2007 21:06 GMT
Will,
I am afraid that in this case you don't have much of a choice other than to
intercept and grab this "pseudo" querystring. I hope there's a ? question
mark there so you can find the beginning of it. Then, you can String.Split to
an array of values based on the & character as the delimiter.
-- Peter
Recursion: see Recursion
site:  http://www.eggheadcafe.com
unBlog:  http://petesbloggerama.blogspot.com
bogMetaFinder:    http://www.blogmetafinder.com

> 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
[quoted text clipped - 21 lines]
>
> will
Will Zachmann - 02 Aug 2007 01:40 GMT
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

Signature

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

> Will,
> I am afraid that in this case you don't have much of a choice other than to
[quoted text clipped - 32 lines]
> >
> > will

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.