开发者

distinguish html link and image link like Facebook attach in .NET

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 distin开发者_运维百科guish a html link or image link

any help?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜