Questions tagged [webclient]

WebClient is a class for .NET Framework applications that provides methods for sending and receiving data from a resource identified by a URI.

Read more about the WebClient class and its usage here: https://learn.microsoft.com/en-us/dotnet/api/system.net.webclient

4098 questions
32
votes
3 answers

How to use verb GET with WebClient request?

How might I change the verb of a WebClient request? It seems to only allow/default to POST, even in the case of DownloadString. try { WebClient client = new WebClient(); …
FlavorScape
  • 13,301
  • 12
  • 75
  • 117
31
votes
6 answers

How to fill forms and submit with Webclient in C#

I'm new at using the the libraries WebClient, HttpResponse and HttpRequest in C#, so bear with me, if my question is confusing to read. I need to build a WinForm based on C# which can open a URL, which is secured with the basic authorization. I did…
Soren Mikkelsen
31
votes
2 answers

How do I log into a site with WebClient?

I want to download something using a WebClient object in C#, but the download domain requires me to be logged in. How can I log in and keep session data using WebClient? I know how to post data with WebClient.
Furkan Gözükara
  • 22,964
  • 77
  • 205
  • 342
30
votes
1 answer

Get WebClient errors as string

I have a diagnostic tool which tests a web service. I want the tool to report when there are problems, so I have deployed a service with a problem with the contract to test it. When I browse to it I get a page with a very descriptive message such…
lockstock
  • 2,359
  • 3
  • 23
  • 39
30
votes
12 answers

C# WebClient disable cache

Good day. I'm using the WebClient class in my C# application in order to download the same file every minute, and then the application performs a simple check to see if the file has been changed, and if it does do something with it. Well since this…
Fábio Antunes
  • 16,984
  • 18
  • 75
  • 96
30
votes
1 answer

How to Replace WebClient with HttpClient?

I have the following WebClient inside my asp.net mvc web application: using (WebClient wc = new WebClient()) // call the Third Party API to get the account id { string url = currentURL + "resources/" + ResourceID + "/accounts?AUTHTOKEN=" +…
John John
  • 1
  • 72
  • 238
  • 501
29
votes
3 answers

C# - How to make a HTTP call

I wanted to make an HTTP call to a website. I just need to hit the URL and dont want to upload or download any data. What is the easiest and fastest way to do it. I tried below code but its slow and after 2nd repetitive request it just goes into…
Mayur J
  • 371
  • 1
  • 7
  • 14
29
votes
4 answers

How to set WebClient Content-Type Header?

To conect to a third party service I need to make a Https Post. One of the requisites set is to sent a custom content type. I'm using WebClient, but I can't find how to set it. I've tried making a new class and overriding the CreateRequest Method,…
MaLKaV_eS
  • 1,325
  • 3
  • 23
  • 39
28
votes
3 answers

How to send request body in spring-boot web client?

I'm facing some problem while sending request body in spring boot web client. Trying to send body like below: val body = "{\n" + "\"email\":\"test@mail.com\",\n" + "\"id\":1\n" + "}" val response =…
Avv
  • 555
  • 1
  • 10
  • 18
27
votes
3 answers

How do I Async download multiple files using webclient, but one at a time?

It has been surprisingly hard to find a code example of downloading multiple files using the webclient class asynchronous method, but downloading one at a time. How can I initiate a async download, but wait until the first is finished until the…
stormist
  • 5,709
  • 12
  • 46
  • 65
26
votes
4 answers

Get original filename when downloading with WebClient

Is there any way to know the original name of a file you download using the WebClient when the Uri doesn't contain the name? This happens for example in sites where the download originates from a dynamic page where the name isn't known beforehand.…
Tim Dams
  • 747
  • 1
  • 6
  • 15
25
votes
2 answers

Does WebClient use KeepAlive?

I need to issue around 50 HTTP requests to a single host (API calls). Performance is important, so I'd like to use HTTP KeepAlive's. Does WebClient support this?
Vilx-
  • 104,512
  • 87
  • 279
  • 422
25
votes
3 answers

System.Net.WebException when using WebClient: Can not create SSL/TLS secure channel

When I execute the following code System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => { return true; }; var webClient = new WebClient(); var s =…
BennoDual
  • 5,865
  • 15
  • 67
  • 153
25
votes
1 answer

WebClient accessing page with credentials

I am trying to access a webpage on a same domain / same asp.net application, that is password protected. Credentials are the same both for webpage firing this call and webpage being accessed. Here is the code, and I don't know why I always end up…
mko
  • 6,638
  • 12
  • 67
  • 118
24
votes
9 answers

How do I check a WebClient Request for a 404 error

I have a program I'm writing that downloads to files. The second file is not neccassary and is only some times included. When the second file is not included it will return an HTTP 404 error. Now, the problem is that when this error is returned it…
Alex Gatti
  • 295
  • 1
  • 2
  • 8