vb.net 如何从原始 URL Visual Basic .NET 获取重定向的 URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13622297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How To Get The Redirected URL From Original URL Visual Basic .NET
提问by Muhammad Saqib
How Can I Get The Redirected URL From Original or Short URL?
如何从原始 URL 或短 URL 获取重定向 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)
那么我们如何从 URL_1 获取 URL_2 呢?请帮忙。(我用谷歌搜索但没有找到任何解决方案)
Project Information:
项目信息:
- Platform: Visual Basic Express 2010
- .NET Framework Version: 2.0
- 平台:Visual Basic Express 2010
- .NET 框架版本: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.
我只有一个 URL,它是 URL_1,我想在 URL1 的帮助下获取 URL_2。
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.
请参阅下图,著名软件如何从 URL_1(短 URL 和已知)立即获取 URL_2(100% 未知字符串)。我想在visual basic .net的程序中做同样的事情。


回答by Muhammad Saqib
My Problem is now solved, thanks to google and Daniwebhere is solution
我的问题现在解决了,多亏了 google 和Daniweb,这里是解决方案
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.
这将返回 URL_2。
回答by w0051977
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
为什么不将原始 URL 作为查询字符串参数传递?即在 url_1 中,重定向到:http://pastehtml.com/view/b95qx66rc.html?redirectfrom=http://goo.gl/ouCeb
Then in url_2 use this code:
然后在 url_2 中使用此代码:
Dim OriginalURL As String = request.querystring("redirectfrom")
回答by iDev
URL_2 = "http://" & URL_1 & "/view/b95qx66rc.html"
URL_2 = "http://" & URL_1 & "/view/b95qx66rc.html"

