webrequest

HttpWebRequest times out on second call

假装没事ソ 提交于 2019-11-26 09:33:50
问题 Why does the following code Timeout the second (and subsequent) time it is run? The code hangs at: using (Stream objStream = request.GetResponse().GetResponseStream()) and then causes a WebException saying that the request has timed out. I have tried this with a WebRequest and HttpWebRequest Edit: It seems the code is falling over in request.GetResponse() Edit: This post suggests it may be a GC issue --> http://www.vbforums.com/showthread.php?t=610043 - as per this post the issue is mitigated

Cannot send a content-body with this verb-type

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 09:24:00
问题 I just got this exception (ProtocolViolationException) in my .NET 2.0 app (running on windows mobile 6 standard emulator). What confuses me is that as far as i know, I have not added any content body, unless I\'ve inadvertently done it somehow. My code is below (very simple). Is there anything else i need to do to convince .NET that this is just a http GET? Thanks, brian //run get and grab response WebRequest request = WebRequest.Create(get.AbsoluteUri + args); request.Method = \"GET\";

Using WebClient or WebRequest to login to a website and access data

↘锁芯ラ 提交于 2019-11-26 09:08:28
问题 I\'m trying to access restricted data on a website using WebClient / WebRequest . There is no official API in that website, so what I\'m trying to do is simply fill the HTML form and post the values to the server, so I\'m logged in. I tried this and this, but it doesn\'t look like the upcoming requests are logged in. The latter example is much more appealing since I obviously prefer WebClient , but legacy WebRequest will do. Anyway, in the first example I think it did login, but the upcoming

how to change originating IP in HttpWebRequest

谁都会走 提交于 2019-11-26 08:11:26
问题 I\'m running this application on a server that has assigned 5 IPs. I use HttpWebRequest to fetch some data from a website. But when I make the connection I have be able to specify which one of the 5 IPs to make the connection from. Does HttpWebRequest support this? If it doesn\'t can I inherit a class from it to change it\'s behavior? I need so ideas here. My code right now is something like: System.Net.WebRequest request = System.Net.WebRequest.Create(link); ((HttpWebRequest)request).Referer

Mono https webrequest fails with “The authentication or decryption has failed”

夙愿已清 提交于 2019-11-26 06:06:31
问题 I\'m making a simple REST client to use in my C# applications. In .net on Windows It works great with http:// and https:// connections. In mono 2.6.7 (Also tested with 2.8 with the same results) on Ubuntu 10.10 only http:// works. https:// connections throw up this exception on the request.GetResponse() method: Unhandled Exception: System.Net.WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure ---> System.IO.IOException: The

HttpWebRequest to URL with dot at the end

余生颓废 提交于 2019-11-26 03:58:12
问题 when i do a GET with WebRequest.Create(\"http://abc/test.\") i get 404 because according to fiddler the trailing dot gets stripped away by .NET and the web server needs the dot. how can i prevent that or work around it. any workaround is appreciated! 回答1: Workaround in workaround tab at the official bug report: https://connect.microsoft.com/VisualStudio/feedback/details/386695/system-uri-incorrectly-strips-trailing-dots?wa=wsignin1.0#tabs .. seems to be valid. Basically, run this code to

Cannot set some HTTP headers when using System.Net.WebRequest

喜你入骨 提交于 2019-11-26 03:50:25
问题 When I try to add a HTTP header key/value pair on a WebRequest object, I get the following exception: This header must be modified using the appropriate property I\'ve tried adding new values to the Headers collection by using the Add() method but I still get the same exception. webRequest.Headers.Add(HttpRequestHeader.Referer, \"http://stackoverflow.com\"); I can get around this by casting the WebRequest object to a HttpWebRequest and setting the properties such as httpWebReq.Referer =\"http

HttpWebRequest using Basic authentication

南笙酒味 提交于 2019-11-26 01:49:15
问题 I\'m trying to go through an authentication request that mimics the \"basic auth request\" we\'re used to seeing when setting up IIS for this behavior. The URL is: https://telematicoprova.agenziadogane.it/TelematicoServiziDiUtilitaWeb/ServiziDiUtilitaAutServlet?UC=22&SC=1&ST=2 (warning: https!) This server is running under UNIX and Java as application server. This is the code I use to connect to this server: CookieContainer myContainer = new CookieContainer(); HttpWebRequest request =

How do I use WebRequest to access an SSL encrypted site using https?

强颜欢笑 提交于 2019-11-26 00:57:57
问题 I\'m writing a program that reads content from a user provided URL. My problem is in the code that goes something like this: Uri uri = new Uri(url); WebRequest webRequest = WebRequest.Create(uri); WebResponse webResponse = webRequest.GetResponse(); ReadFrom(webResponse.GetResponseStream()); And this is breaking if the provided url is an \"https://\" URL. Can anyone help me with changing this code so that it will work with SSL encrypted content. Thanks. 回答1: You're doing it the correct way but

How do I use WebRequest to access an SSL encrypted site using https?

丶灬走出姿态 提交于 2019-11-25 20:43:08
I'm writing a program that reads content from a user provided URL. My problem is in the code that goes something like this: Uri uri = new Uri(url); WebRequest webRequest = WebRequest.Create(uri); WebResponse webResponse = webRequest.GetResponse(); ReadFrom(webResponse.GetResponseStream()); And this is breaking if the provided url is an "https://" URL. Can anyone help me with changing this code so that it will work with SSL encrypted content. Thanks. LukeDuff You're doing it the correct way but users may be providing urls to sites that have invalid SSL certs installed. You can ignore those cert