Sign in to follow this  

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

This topic is 3587 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
"application/x-www-form-urlencoded".

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:

name1=value1&name2=value2

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

This topic is 3587 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this