Reverse Those Short URLs

2. February 2011 02:58

ASP.NET Utils  0 Comments

Bit.ly is one of the major short URL service provider. There are other also but Bit.ly is used by most of the users because of it's simplicity, API and statistics. But some notorious users create short URLs for the spam sites which doesn't make any sense to us. As you know by looking at the short URLs, they won't reveal anything. But there is a way to get the original/long URL through ASP.NET.

Below is the method which takes short URL as a parameter.

public static string ReverseShortURL(string ShortURL)
{
        HttpWebRequest Webrequest = (HttpWebRequest)HttpWebRequest.Create(ShortURL);
        HttpWebResponse Webresponse = (HttpWebResponse)Webrequest.GetResponse();
        Uri uri = Webresponse.ResponseUri;
        return uri.AbsoluteUri;
}

The Response.Uri will get the actual URL which is being requested.

 

Demo: http://demo.midnightprogrammer.net/ASPNET/ReverseURL/Default.aspx

Download: ReverseShortURL.zip (335.87 kb)

 No Rating

Comments (0)

Add Comment

Visit blogadda.com to discover Indian blogs Computers Blogs