Using this code u can post information to the secure site through http post method.
        using System.Net;
        using System.IO;
        using System.Text;
        using System.Security.Cryptography;
        string  strinput="sample Data" // According to your requirement
        string strresult = "";
       
        string strurl ="https://sitename.com";
        Uri url = new Uri(strurl);
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        req.ContentLength = strinput.Length;
        Stream writeStream = req.GetRequestStream();
        UTF8Encoding encoding = new UTF8Encoding();
        byte[] bytes = encoding.GetBytes(strinput);
        writeStream.Write(bytes, 0, bytes.Length);
        writeStream.Close();
        HttpWebResponse response = (HttpWebResponse)req.GetResponse();
        Stream responseStream = response.GetResponseStream();
        StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8);
        strresult = readStream.ReadToEnd();
        return strresult;        //Result in Success or Not Success
No comments:
Post a Comment