httpwebrequest

c# httpwebrequest getResponse() freezes and hangs my program

痴心易碎 提交于 2020-01-14 07:42:32
问题 I was trying to use httpwebrequest to use a rest like service on a remote server and from the first execution itself, my code was hanging the program. Then I tried it as a console application to make sure it has nothing to do with the program itself but no luck! string credentialsJson = @"{""username"":""test"", ""password"":""test"" }"; int tmp = ServicePointManager.DefaultConnectionLimit; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"https://qrua.com/qr/service" + @"/auth

HttpWebRequest one proxy and one not

♀尐吖头ヾ 提交于 2020-01-13 10:04:22
问题 How do i proxy my connections? i want 3 default HttpWebRequest objs that will not go through a proxy and another 3 that does. Do i do WebRequestObject.Proxy = myProxy; on objects i want to use a proxy on and do nothing on the 3 objs i do not? also the objects will initialize in an unknown order so i may have 2 not, 2 that is proxied, a 3rd that isnt and a final that is. Is it just simply writing .Proxy = myProxy? 回答1: For requests that require a proxy, yes, that'll work fine: request.Proxy =

Upload large file to JBoss Issue from Asp.net Client

可紊 提交于 2020-01-13 07:28:06
问题 All , I had a JBoss application which uses apache-common-fileupload component, I had tested it can be uploaded large file from a asp.net Client which use HttpWebRequest in post method. But after several times of successful upload.It failed with a exception below in JBoss console. Please help to check it .Thanks. org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly at org.apache.commons.fileupload

Can I make HttpWebRequest include windows credentials without waiting for a 401 challenge?

試著忘記壹切 提交于 2020-01-12 13:54:43
问题 My app communicates with an internal web API that requires authentication. When I send the request I get the 401 challenge as expected, the handshake occurs, the authenticated request is re-sent and everything continues fine. However, I know that the auth is required. Why do I have to wait for the challenge? Can I force the request to send the credentials in the first request? My request generation is like this: private static HttpWebRequest BuildRequest(string url, string methodType) { var

Can I make HttpWebRequest include windows credentials without waiting for a 401 challenge?

社会主义新天地 提交于 2020-01-12 13:51:06
问题 My app communicates with an internal web API that requires authentication. When I send the request I get the 401 challenge as expected, the handshake occurs, the authenticated request is re-sent and everything continues fine. However, I know that the auth is required. Why do I have to wait for the challenge? Can I force the request to send the credentials in the first request? My request generation is like this: private static HttpWebRequest BuildRequest(string url, string methodType) { var

HttpWebRequest returning “The remote server returned an error: NotFound” on Windows Phone 7

元气小坏坏 提交于 2020-01-12 05:28:26
问题 I am trying to authenticate against the Huddle API using the Windows Phone 7 Emulator. However, I am not getting any success. I keep getting "The remote server returned an error: NotFound". I have even tried "dumbing down" my code and just trying a straight web site, eg. Google but still get the same result. I have the following code: string url = "http://www.google.com"; HttpWebRequest client= WebRequest.CreateHttp(new Uri(url)) as HttpWebRequest; client.AllowReadStreamBuffering = true; //

System.Net.WebException: The operation has timed out

落花浮王杯 提交于 2020-01-11 15:47:51
问题 I have a big problem: I need to send 200 objects at once and avoid timeouts. while (true) { NameValueCollection data = new NameValueCollection(); data.Add("mode", nat); using (var client = new WebClient()) { byte[] response = client.UploadValues(serverA, data); responseData = Encoding.ASCII.GetString(response); string[] split = Javab.Split(new[] { '!' }, StringSplitOptions.RemoveEmptyEntries); string command = split[0]; string server = split[1]; string requestCountStr = split[2]; switch

.NET HttpWebRequest oAuth 401 Unauthorized

二次信任 提交于 2020-01-11 13:47:09
问题 I need to consume a web resource from a VB.NET app. I have successfully retrieved the access token and am ready to use it to make calls to the protected resource. However, everytime I call the protected resource I receive a 401 Unauthorized response because the Authorization field has not been added to the header. Here is my code. WebRequest = DirectCast(Net.WebRequest.Create(ApiUri), HttpWebRequest) WebRequest.Method = "POST" WebRequest.ContentType = "application/json" WebRequest

Web request Content type is always text/html

风流意气都作罢 提交于 2020-01-11 11:28:11
问题 I have a web api I need to use. This api will return the data according the content type I'm sending. Normally it will return html response. If the request has Content-Type header with the 'application/json' header it will return a json response. When I try it using Postman and adding the content-type header (as application/json) everything is good. But when trying it using C# WebRequest object I'm always getting the html response regardless the content-type header I'm using. I've used

Web request fails, but only for localhost and when using System.Net.HttpWebRequest

大城市里の小女人 提交于 2020-01-11 08:33:07
问题 I've got a very weird problem with System.Net.HttpWebRequest , that's driving me nuts: When I run it with a localhost address, then it is either extremely slow (around 30 sec) or, in most cases, it times out entirely. This happens only with requests that target localhost , and only from C# code. Concretely, taking an ASP.NET Web API project as an example, when I have this code: [Test] public void TestRequest() { var request = WebRequest.Create("http://localhost:64497/api/values"); WebResponse