How to know redirect URL [duplicate]
Possible Duplicate:
A way to figure out redirection URL
C# Issue:
If we type the following url (see warning) http://migre.me/13rQa
It will redirect to oooooo1.ru
I like to know the redirected URL from C#. Anybody knows how to do it.
P.S: These mentioned URL could be virus affe开发者_如何学Pythoncted. Please use on own risk
If migre.me has some kind of an API, maybe they can provide you with a "preview" of the site you'll be redirected to.
If they don't, you'll have to create an HttpWebRequest and see the Uri of the response.
e.g.
WebRequest request = WebRequest.Create("http://migre.me/13rQa");
var response = request.GetResponse();
With that code, the response.ResponseUri property will have the address you'll be redirected.
Hope this helps you
If you're using HttpWebRequest
, set AllowAutoRedirect
to false. You'll then get to see the redirect yourself. Note that this only applies to HTTP-level redirects, not meta redirects within HTML.
(I don't know offhand whether it will throw an exception, but even if it does you can examine the response to find out the status code and the data including the redirection.)
精彩评论