3

Is there a built-in .NET class that can replace or work like WinHttp.WinHttpRequest?

Thanks!

Leon Tayson
  • 4,741
  • 7
  • 37
  • 36

1 Answers1

6

There is the System.Net.HttpRequest class:

HttpWebRequest Class

Provides an HTTP-specific implementation of the WebRequest class.

  • Namespace: System.Net
  • Assembly: System (in System.dll)

You can alternatively use the System.Net.WebClient class:

WebClient Class

Provides common methods for sending data to and receiving data from a resource identified by a URI.

  • Namespace: System.Net
  • Assembly: System (in System.dll)

This class simplifies some common tasks, like downloading a file (method DownloadFile)

The WebClient class provides common methods for sending data to or receiving data from any local, intranet, or Internet resource identified by a URI.

The WebClient class uses the WebRequest class to provide access to resources. WebClient instances can access data with any WebRequest descendant registered with the WebRequest.RegisterPrefix method.

splattne
  • 102,760
  • 52
  • 202
  • 249
  • Thanks! I think i'll be using the WebClient class to upload text files. I've created some codes for the upload and it seems to be uploading the files because the UploadFile method executes without any exception, but i still have to find where the files are being uploaded. Any ideas? – Leon Tayson Dec 30 '08 at 13:30
  • The files are uploaded to the URI you provide. you should check the server implementation (form handling). WebClient does the client part. I hope this helps. – splattne Dec 30 '08 at 13:55