1

This the the curl request I need to make in C#:

curl -X PURGE http://www.example.com/image.jpg

It is the PURGE part that is throwing me off, I was going to do this in RestSharp but WebClient or whatever will work just fine as well.

ManoDestra
  • 6,325
  • 6
  • 26
  • 50
Slee
  • 27,498
  • 52
  • 145
  • 243

1 Answers1

2

I find HttpClient to be a convenient way to send requests these days. The key is to recognize that you can create a custom HttpMethod by passing a string to its constructor.

using (var client = new HttpClient())
using (var request = new HttpRequestMessage(
    new HttpMethod("PURGE"), 
    new Uri("http://www.example.com/image.jpg")))
using (var response = await client.SendAsync(request))
{
    // work with response
}
Community
  • 1
  • 1
StriplingWarrior
  • 151,543
  • 27
  • 246
  • 315