Created
March 29, 2010 14:15
-
-
Save aqlong/347870 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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