greee
December 4th, 2008, 02:38 PM
Ive read a bunch of posts indicating this is mostly about needing to have an other than Private member. . .but I cant seem to make this work no matter what I make public. . .what am I doing wrong. Im a newbie to 2008.Net and C#! Any help is greatly appreciated.
using System;
using System.Text;
using System.IO;
using System.Web;
using System.Net;
using System.Collections.Specialized;
public static void Main(string[] args)
{
// Set the 'Method' property of the 'Webrequest' to 'POST'.
HttpWebRequest myHttpWebRequest = new HttpWebRequest();
myHttpWebRequest.Method = "POST";
Console.WriteLine("\nPlease enter the data to be posted to the (http://www.ias.net) Uri :");
// Create a new string object to POST data to the Url.
string inputData = Console.ReadLine();
string postData = "Request=" + inputData;
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] byte1 = encoding.GetBytes(postData);
// Set the content type of the data being posted.
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
// Set the content length of the string being posted.
myHttpWebRequest.ContentLength = byte1.Length;
Stream newStream = myHttpWebRequest.GetRequestStream();
newStream.Write(byte1, 0, byte1.Length);
Console.WriteLine("The value of 'ContentLength' property after sending the data is {0}", myHttpWebRequest.ContentLength);
// Close the Stream object.
newStream.Close();
}
using System;
using System.Text;
using System.IO;
using System.Web;
using System.Net;
using System.Collections.Specialized;
public static void Main(string[] args)
{
// Set the 'Method' property of the 'Webrequest' to 'POST'.
HttpWebRequest myHttpWebRequest = new HttpWebRequest();
myHttpWebRequest.Method = "POST";
Console.WriteLine("\nPlease enter the data to be posted to the (http://www.ias.net) Uri :");
// Create a new string object to POST data to the Url.
string inputData = Console.ReadLine();
string postData = "Request=" + inputData;
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] byte1 = encoding.GetBytes(postData);
// Set the content type of the data being posted.
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
// Set the content length of the string being posted.
myHttpWebRequest.ContentLength = byte1.Length;
Stream newStream = myHttpWebRequest.GetRequestStream();
newStream.Write(byte1, 0, byte1.Length);
Console.WriteLine("The value of 'ContentLength' property after sending the data is {0}", myHttpWebRequest.ContentLength);
// Close the Stream object.
newStream.Close();
}