DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 1 Aug 2007 10:46:05 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Will Zachmann
          2    Peter Bromberg [C# MVP]
                 3    Will Zachmann


Request.Querystring handling without name/value pairs   
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

-- 
William F. Zachmann
Canopus Research Inc.
http://www.canopusresearch.com
Date:Wed, 1 Aug 2007 10:46:05 -0700   Author:  

RE: Request.Querystring handling without name/value pairs   
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



"Will Zachmann" wrote:


> 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
> 
> -- 
> William F. Zachmann
> Canopus Research Inc.
> http://www.canopusresearch.com
Date:Wed, 1 Aug 2007 13:06:02 -0700   Author:  

RE: Request.Querystring handling without name/value pairs   
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


"Peter Bromberg [C# MVP]" wrote:


> 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
> 
> 
> 
> "Will Zachmann" wrote:
> 
> > 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
> > 
> > -- 
> > William F. Zachmann
> > Canopus Research Inc.
> > http://www.canopusresearch.com
Date:Wed, 1 Aug 2007 17:40:00 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us