This tutorial will show you how to get youtube video thumbnail image in ASP.NET. Write the following code that returns image thumbnail url of given youtube video url by passing video url as a parameter in getYouTubeThumbnail method.

public string getYouTubeThumbnail(string YoutubeUrl)   
{   
    string youTubeThumb=string.Empty;   
    if (YoutubeUrl == "")   
        return "";   
 
    if (YoutubeUrl.IndexOf("=") > 0)   
    {   
        youTubeThumb = YoutubeUrl.Split('=')[1];   
    }   
    else if (YoutubeUrl.IndexOf("/v/") > 0)   
    {   
        string strVideoCode = YoutubeUrl.Substring(YoutubeUrl.IndexOf("/v/") + 3);   
        int ind = strVideoCode.IndexOf("?");   
        youTubeThumb = strVideoCode.Substring(0, ind == -1 ? strVideoCode.Length : ind);   
    }   
    else if (YoutubeUrl.IndexOf('/') < 6)   
    {   
        youTubeThumb = YoutubeUrl.Split('/')[3];   
    }   
    else if (YoutubeUrl.IndexOf('/') > 6)   
    {   
        youTubeThumb = YoutubeUrl.Split('/')[1];   
    }   
 
    return "http://img.youtube.com/vi/" + youTubeThumb + "/mqdefault.jpg";   
}   

You may call the above function with various youtube url format like,
getYouTubeThumbnail("http://youtu.be/4e3qaPg_keg");   
getYouTubeThumbnail("http://www.youtube.com/watch?v=bvLaTupw-hk");

HostForLIFE.eu ASP.NET Core 1.0 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.