0

like facebook attach link,

when i share a link -> facebook fetch the html page

when i share a image link -> facebook fetch the image

so at server side (.NET, C#), how can i distinguish a html link or image link

any help?

vNext
  • 1,102
  • 4
  • 16
  • 28
  • possible duplicate of [Regex to check if valid URL that ends in .jpg, .png, or .gif](http://stackoverflow.com/questions/169625/regex-to-check-if-valid-url-that-ends-in-jpg-png-or-gif) – Merlyn Morgan-Graham Jul 16 '11 at 06:18

1 Answers1

1

You could try a couple things:

  • Do a regex on the URL and check for a file extension. E.g. \.(png|jpg|gif|bmp)$
  • Actually retrieve the document, and check the mime type

Also, check answers to this question:

Regex to check if valid URL that ends in .jpg, .png, or .gif

The most recent answer there mentions a library called FastImage.

Community
  • 1
  • 1
Merlyn Morgan-Graham
  • 58,163
  • 16
  • 128
  • 183