How To Get The Redirected URL From Original URL Visual Basic .NET

 ̄綄美尐妖づ 提交于 2020-01-01 15:37:51

问题


How Can I Get The Redirected URL From Original or Short URL?

for example:

    URL_1 (Short URL) = "http://af.ly/FQhAo"

This will redirect to

    URL_2 (Original URL) = "http://download.bitdefender.com/windows/desktop/t_security/2013/en-us/bitdefender_ts_2013_32b.exe"

So how can we get URL_2 From URL_1? help Please. (I have googled but not found any solution)

Project Information:

  • Platform: Visual Basic Express 2010
  • .NET Framework Version: 2.0

Thanks For Your Time. Edited:

I just have one URL which is URL_1, and I want to get the URL_2 with the help of URL1.

See The Image below, How a famous Software getting URL_2 (which is 100% unknown string) From URL_1 (which is short URL and Known) instantly. I want to do same in my program in visual basic .net.


回答1:


My Problem is now solved, thanks to google and Daniweb here is solution

Dim req As HttpWebRequest = DirectCast(HttpWebRequest.Create("Your short URL here"), HttpWebRequest)
        Dim response As HttpWebResponse
        Dim resUri As String
        response = req.GetResponse
        resUri = response.ResponseUri.AbsoluteUri
        MsgBox(resUri)

this will return URL_2.




回答2:


Why don't you pass the original URL as a query string parameter? i.e. in url_1, redirect to: http://pastehtml.com/view/b95qx66rc.html?redirectfrom=http://goo.gl/ouCeb

Then in url_2 use this code:

Dim OriginalURL As String = request.querystring("redirectfrom")



回答3:


URL_2 = "http://" & URL_1 & "/view/b95qx66rc.html"



来源:https://stackoverflow.com/questions/13622297/how-to-get-the-redirected-url-from-original-url-visual-basic-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!