webrequest

HttpWebResponse get stuck while running in a loop

荒凉一梦 提交于 2020-02-14 09:21:16
问题 I build this method (c#) in order to receive the HTTP response status code from an URL. whene I run this method ones it's works fine, but when I run it in a loop, the third time its stuck. any clue?? public static string isAlive(string url) { Console.WriteLine("start: Is Alive Test"); WebRequest request = WebRequest.Create(url); try { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); return Convert.ToString((int)response.StatusCode); } catch(WebException ex) { HttpWebResponse

HttpWebResponse get stuck while running in a loop

人盡茶涼 提交于 2020-02-14 09:20:23
问题 I build this method (c#) in order to receive the HTTP response status code from an URL. whene I run this method ones it's works fine, but when I run it in a loop, the third time its stuck. any clue?? public static string isAlive(string url) { Console.WriteLine("start: Is Alive Test"); WebRequest request = WebRequest.Create(url); try { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); return Convert.ToString((int)response.StatusCode); } catch(WebException ex) { HttpWebResponse

My webrequest is not working get 400 error message?

杀马特。学长 韩版系。学妹 提交于 2020-01-25 07:54:06
问题 My webrequest is not working? I got an error. The website where I'm doing this request is: https://www.marktplaats.nl/account/login.html can anyone help me perform this request? I'm stuck with getting error message HTTP 400 Bad Request. This is my method: using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; namespace MPRequest { class HttpMethods { public static string Get(string url, string

Powershell - Invoke-WebRequest to a URL with literal '/' (%2F) in it

早过忘川 提交于 2020-01-22 14:32:31
问题 I have been trying to access a URL with a / character in it from powershell, using the following command (it's a query to a gitlab server to retrieve a project called "foo/bar" ): Invoke-WebRequest https://server.com/api/v3/projects/foo%2Fbar -Verbose Now, the odd thing is that using the PowerShell ISE or Visual Studio, the request is OK. When using PowerShell itself, the URL is automatically un-escaped and the request fails. E.g. In ISE/VS: $> Invoke-WebRequest https://server.com/api/v3

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

Silverlight ClientHttp WebRequest timeout

一个人想着一个人 提交于 2020-01-13 10:25:10
问题 I have a silverlight 4 application using the ClientHttp stack to make a WebRequest which serves a binary stream. I then read from this stream and do stuff. However, I have the following problem: the server buffers the data that it sends down, so that the send process is like send-pause-send-pause-send... Sometimes the server takes a little longer pause (around 20 seconds), at which point the connection seems to somehow break. I don't get any exception in Silverlight, actually to the code it

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

using chrome.experimental.webRequest API to change loaded file?

≡放荡痞女 提交于 2020-01-11 06:21:10
问题 I'm trying to use webRequest API to change the loaded .swf file on a webpage... The page loads a file called chat.swf, but i want to redirect to chat2.swf in the same directory in order to use the other file. I was told that this could work, but I have no idea how to use this API correctly and I cannot find any examples @_@ function incerceptChat(chat){ console.log( "onBeforeRequest", details ); if(chat.url == swf1){ chat = swf2; } } that's my function that's supposed to change the URL, but I

c# WebRequest using WebBrowser cookie

陌路散爱 提交于 2020-01-09 05:08:05
问题 I am logging into a site using a WebBrowser, then i want use regex to get some data , but webRequest didnt use web Browse cookie , my webBrowser is in public , is there any way to using WebBrowser cookie in webRequest ? 回答1: public CookieContainer GetCookieContainer() { CookieContainer container = new CookieContainer(); foreach (string cookie in webBrowser1.Document.Cookie.Split(';')) { string name = cookie.Split('=')[0]; string value = cookie.Substring(name.Length + 1); string path = "/";

Stream PDF from a server to a web client vb.net

三世轮回 提交于 2020-01-06 15:01:13
问题 We have a servlet that will deliver PDF reports to a browser. We also have a IIS server running .net apps and we want to return the PDF from the servlet as a stream to the .Net app and then the .Net app would render the PDF to the browser (we are using this technique for reason I don't need to go into here). I am not much of a VB/ Visual Studio devloper by this code works by using a web request: Dim BUFFER_SIZE As Integer = 1024 ' Create a request for the URL. Dim serveraction As String =