C#.NET HTTP Headers
Posted: Tue Feb 26, 2008 10:44 am
If anyone's familiar with C#;
It does work, however after 2 times Sending the Post Header the tool will freeze, which I cannot explain to myself. I've tried opening the stream already just on pressing start and closing it later, but that didn't helped either.
The original is from
http://en.csharp-online.net/HTTP_Post
And theres no offtopic forum
Code: Select all
public class PostUtility
{
public static string HttpPost(string uri, string parameters)
{
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Headers.Add("Cookie: xxxxx");
webRequest.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes(parameters);
Stream os = null;
try
{
webRequest.ContentLength = bytes.Length;
os = webRequest.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
}
finally
{
if (os != null)
{
os.Close();
}
}
return null;
}
}
The original is from
http://en.csharp-online.net/HTTP_Post
And theres no offtopic forum
