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
  • 5,756
  • 6
  • 22
  • 48
Slee
  • 24,982
  • 48
  • 139
  • 237

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
  • 135,113
  • 24
  • 223
  • 283