0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.