View Single Post
 
Old June 7th, 2003, 04:02 PM
NotNowJohn NotNowJohn is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: Wien, Wien, Austria.
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

Try this...

Code:
HttpWebRequest req=WebRequest.Create(url_to_send); 
req.Method="POST";
req.ContentType = "application/x-www-form-urlencoded";


StringBuilder prepared_string = new StringBuilder();
string_to_send="username="+Username+"&password="+Password;
Char[] reserved = {'?', '=', '&'};
byte[] bytes_to_send = null;

int i=0, j;
        while(i<string_to_send.Length)
    {
        j=string_to_send.IndexOfAny(reserved, i);
        if (j==-1)
        {
            prepared_string.Append(HttpUtility.UrlEncode(string_to_send.Substring(i, string_to_send.Length-i)));
            break;
                }
    prepared_string.Append(HttpUtility.UrlEncode(string_to_send.Substring(i, j-i)));
    prepared_string.Append(string_to_send.Substring(j,1));
    i = j+1;
        }

bytes_to_send = Encoding.UTF8.GetBytes(prepared_string.ToString());
req.ContentLength = bytes_to_send.Length;

WebResponse wresp=req.GetResponse();
Stream strim=wresp.GetResponseStream();
StreamReader sr=new StreamReader(strim);
string line;
while ((line=sr.ReadLine())!=null)
    {
        //processing line variable
    }
strim.Close();
...but the Soon is eclipsed by the Moon