A Conversation for The H2G2 Programmers' Corner
Extracting CGI Parameters in C#
Jonny Started conversation Jun 7, 2003
Hi everyone!
I'm experimenting with CGI, and I'm very new to it. I'm trying to pass an argument from an HTML form to a CGI program which I've written in C#. I'm extracting the parameter from the form using:
string t = System.Environment.GetEnvironmentVariable("QUERY_STRING");
But this produces an output with the special characters represented as "?txt=Hello+there%21", is there a way I can get that back to it's original form which was "Hello there!" using C#?
I think it will have to involve me creating a sort of find and replace routine, to translate the % entities and extract the hex code after the % sign.
I was just wondering if anybody knew a standard way of doing it?
Thanks,
Jonny
Extracting CGI Parameters in C#
Ion the Naysayer Posted Jun 7, 2003
If you know Perl you may want to look at the source for CGI.pm and see how its decoding works. Parameter decoding has a few gotchas that even experienced developers frequently miss - both the Nimda and Cod Red worms exploit bugs in the URL decoding in Microsoft's Internet Information Server, for example.
Key: Complain about this post
Extracting CGI Parameters in C#
More Conversations for The H2G2 Programmers' Corner
Write an Entry
"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."