views:

414

answers:

1

I'm running a C# program as a CGI script in Apache on Windows, which works just fine. However, I'm now trying to pass it query parameters, e.g.

http://localhost/cgi-bin/csharp_program.exe?hello=kitty&goodbye=world

I understand that my query parameters will be passed in the QUERY_STRING environment variable, e.g.

`hello=kitty&goodbye=world`

What functions/classes in C# exist to parse these query parameters for me so that I don't need to reinvent the wheel and do it myself?

+1  A: 

Check out System.Web.HttpRequest. In .NET 3.5 it has a public constructor that takes a file, URL, and query string. I've never used it in a CGI process, but you could probably fake the file and URL. Then you can access the QueryString property which is a NameValueCollection.

You could also go the reflection route and create an instance of HttpValueCollection (internal to System.Web) which is a NameValueCollection.

Justin Rudd