httpwebrequest

Serialize XmlDocument & send via HTTPWebRequest

心已入冬 提交于 2020-01-11 07:11:09
问题 I'm trying to figure out how to properly serialize my XmlDocument and send it via a HTTPWebRequest object. Here's what I have thus far: Stream requestStream; HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://wwwcie.ups.com/ups.app/xml/Track"); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = postData.Length; requestStream = request.GetRequestStream(); XmlSerializerNamespaces xsm = new XmlSerializerNamespaces(); xsm

HttpWebRequest results in “The request was aborted: Could not create SSL/TLS secure channel”

↘锁芯ラ 提交于 2020-01-10 05:01:05
问题 We've introduced a few .NET pages into a Classic ASP application. When a user hits one of the .NET pages we use an HttpWebRequest to get session variable values from the ASP side by sending the request to a Class ASP page with the name of the session variable we want. This approach works, except in the following situation. On our production servers our IT folks have disabled the weak cipher algorithms with some registry hacking. We want to force 128 over 128 (or so I'm told by people who know

Android Read contents of a URL (content missing after in result)

巧了我就是萌 提交于 2020-01-09 10:24:00
问题 I have the following code that reads the content of a url public static String DownloadText(String url){ StringBuffer result = new StringBuffer(); try{ URL jsonUrl = new URL(url); InputStreamReader isr = new InputStreamReader(jsonUrl.openStream()); BufferedReader in = new BufferedReader(isr); String inputLine; while ((inputLine = in.readLine()) != null){ result.append(inputLine); } }catch(Exception ex){ result = new StringBuffer("TIMEOUT"); Log.e(Util.AppName, ex.toString()); } in.close();

HttpWebRequest.GetResponse throws WebException on HTTP 304

不想你离开。 提交于 2020-01-09 06:20:48
问题 When a web server responds to HttpWebRequest.GetResponse() with HTTP 304 (Not Modified), GetResponse() thows a WebException , which is so very weird to me. Is this by design or am I missing something obvious here? 回答1: Ok, this seems to be a by-design behavior and a perfect example of a vexing exception. This can be solved with this: public static HttpWebResponse GetHttpResponse(this HttpWebRequest request) { try { return (HttpWebResponse) request.GetResponse(); } catch (WebException ex) { if

HttpWebRequest.GetResponse throws WebException on HTTP 304

时光怂恿深爱的人放手 提交于 2020-01-09 06:20:46
问题 When a web server responds to HttpWebRequest.GetResponse() with HTTP 304 (Not Modified), GetResponse() thows a WebException , which is so very weird to me. Is this by design or am I missing something obvious here? 回答1: Ok, this seems to be a by-design behavior and a perfect example of a vexing exception. This can be solved with this: public static HttpWebResponse GetHttpResponse(this HttpWebRequest request) { try { return (HttpWebResponse) request.GetResponse(); } catch (WebException ex) { if

WebRequest.GetRequestStreamAsync() method timesout each time for MNS access token

这一生的挚爱 提交于 2020-01-06 14:54:38
问题 I am trying to get the access token from MNS for Push notifications and the WebRequest.GetRequestStreamAsync() method timesout each time. Any suggestions? Reference: http://msdn.microsoft.com/en-us/library/windows/apps/hh913756.aspx Below is the code I use HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create("https://login.live.com/accesstoken.srf"); webRequest.Method = "POST"; webRequest.ContentType = "application/x-www-form-urlencoded"; string postString = String.Format("grant

MvvmCross HTTP DownloadCache with authentication

天涯浪子 提交于 2020-01-06 14:07:26
问题 In my app, the user need to be authenticated on the server to download data using WebAPIs. The MvvmCross DownloadCache plugin seems to handle only basic HTTP GET queries. I can't add my authentication token in the url as it's a big SAML token. How can I add a HTTP header to queries done through DownloadCache plugin ? With the current version I think I should inject my own IMvxHttpFileDownloader but I'm looking for an easier solution. Injecting my own MvxFileDownloadRequest would be better

HttpWebRequest and HttpWebResponse in C#

给你一囗甜甜゛ 提交于 2020-01-06 11:48:55
问题 How to use HttpWebRequest and HttpWebResponse to create a webservice and how will the request and responses will be send across the wire? 回答1: this is the syntax for using HttpWebRequest and HttpWebResponse WebRequest _request; string text; string url = "UrlToGet"; _request = (HttpWebRequest)WebRequest.Create(url); using (WebResponse response = _request.GetResponse()) { using (StreamReader reader =new StreamReader(response.GetResponseStream())) { text = reader.ReadToEnd(); } } 回答2:

HttpWebRequest and HttpWebResponse in C#

家住魔仙堡 提交于 2020-01-06 11:47:09
问题 How to use HttpWebRequest and HttpWebResponse to create a webservice and how will the request and responses will be send across the wire? 回答1: this is the syntax for using HttpWebRequest and HttpWebResponse WebRequest _request; string text; string url = "UrlToGet"; _request = (HttpWebRequest)WebRequest.Create(url); using (WebResponse response = _request.GetResponse()) { using (StreamReader reader =new StreamReader(response.GetResponseStream())) { text = reader.ReadToEnd(); } } 回答2:

problem using proxy with HttpWebRequest in C#

只谈情不闲聊 提交于 2020-01-06 08:57:08
问题 I'm using this code to use proxy with HttpWebRequest public string GetBoardPageResponse(string url, string proxy = "") { ServicePointManager.Expect100Continue = false; HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest; HttpWebResponse response = null; WebProxy myProxy = new WebProxy(proxy); request.Proxy = myProxy; request.Timeout = 20000; request.ReadWriteTimeout = 20000; request.Accept = "*/*"; request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2