Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending HTTP requests with C# HttpWebRequest or WebClient?

Tags:

c#

http

I can use both HttpWebRequest to send an HTTP request and get an HTTP response without a WebClient.

When should you use HttpWebRequest and when should you use WebClient?

like image 839
skywalker Avatar asked Nov 09 '10 13:11

skywalker


1 Answers

WebClient can be used when you don't need any fine-tuning.

When using HttpWebRequest, you can control various options, including timeouts (very important). So basically - WebClient for toy projects / POCs, HttpWebRequest for actual business.

like image 55
ripper234 Avatar answered Oct 06 '22 19:10

ripper234