Jump to content
  • Advertisement
Sign in to follow this  

C# Using the webRequest class to send data to a CGI

This topic is 3925 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm currently working on a small project close to completion but I'm struggling to find information on what a CGI actually expects to receive. what I aim to have the program do is send data using the webRequest class direct to a CGI instead of filling out the form on the html page. The information I'm after is what type of variables are sent from the a html form to a CGI and is there more to consider than the type of variable to send. Say the form has <input="text" name="name"> am I even on the right track in thinking I could send the content of a System.Window.Form.TextBox in some as some thing like. name = System.Windows.Form.TextBox.Text; The other input types I'd also need to be able to send would be the value of a type = checkBox and the option value of a select. Appreciate any help Ramearess

Share this post

Link to post
Share on other sites
I found this information just now and believe it will be useful as now all I need to do is search for how to set the method (post in this case)and seting the contentType.

You will use the HttpWebRequest class just as you did before. However,
this time, you need to set the Method property to "POST", which will
indicate that you are posting data. Also, you will have to call
GetRequestStream, and write to the stream the content of the forms data.

First, you need to set the ContentType property to

Then, you have to find the ids of the controls that are going to send
information. You will have to then write to the Stream returned by
GetRequestStream the values in the following manner:


You have to make sure that the values are encoded correctly, as certain
characters are not allowed.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!