Can anyone please send me code to use “System.Net.HttpWebRequest” with post method and I need to pass some parameters to webpage.As the url is exceding more than 350 characters I have to use post method.
Answer:
This code may help
string strNewValue;
string strResponse;
string strResponse;
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentType = "application/x-www-form-urlencoded";
//Parameters
strNewValue = strFormValues + "¶m1=value1&parm2=value2";
req.ContentLength = strNewValue.Length;
strNewValue = strFormValues + "¶m1=value1&parm2=value2";
req.ContentLength = strNewValue.Length;
//Request
StreamWriter stOut = new StreamWriter (req.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write(strNewValue);
stOut.Close();
stOut.Write(strNewValue);
stOut.Close();
//Response
StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream());
strResponse = stIn.ReadToEnd();
stIn.Close();
strResponse = stIn.ReadToEnd();
stIn.Close();
please provide your comments:
0 comments:
கருத்துரையிடுக