Skip to content

Instantly share code, notes, and snippets.

@aqlong
Created March 29, 2010 14:15
Show Gist options
  • Save aqlong/347870 to your computer and use it in GitHub Desktop.
Save aqlong/347870 to your computer and use it in GitHub Desktop.
HtmlString = HtmlString.Replace("&", "__amp__");
String _postData = String.Format("data={0}", HtmlString);
System.Text.Encoding encoding = new System.Text.UTF8Encoding();
byte[] _data = encoding.GetBytes(_postData);
HttpWebRequest _request = WebRequest.Create(_Html2PdfUrl) as HttpWebRequest;
_request.Method = WebRequestMethods.Http.Post;
_request.ContentType = "application/x-www-form-urlencoded";
_request.ContentLength = _data.Length;
Stream sw = _request.GetRequestStream();
sw.Write(_data, 0, _data.Length);
sw.Close();
using (HttpWebResponse response = _request.GetResponse() as HttpWebResponse)
{
String ContentType = response.ContentType;
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.ASCII);
// Read the whole contents and return as a string
_Result = reader.ReadToEnd();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment