GEt The Response URl

J

Jon Skeet [C# MVP]

Rajkiran R.B. said:
Whenever I type some url like

http://youtube.com/watch/v/54GRe3ox_xI

in firefox browser when the address is immediately redirected to

http://youtube.com/swf/l.swf?video_id=54GRe3ox_xI&rel=1&eurl=&iurl=
http%3A//i.ytimg.com/vi/54GRe3ox_xI/default.jpg&t=OEgsToPDskJ98NGh0lWiWIogmOD9369L

Is there a way in C# to get the above url

I tried implementing Using The HttpWebRequest And HttpWebResponse Class but
no use

It should be fine with HttpWebRequest. You should get a 302 back.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
N

Nicholas Paldino [.NET/C# MVP]

Rajkiran,

You have to set the AllowAutoRedirect property on the HttpWebRequest
instance to false (the default is true). When this property is true, it
will automatically redirect the request on a 302 response to the URL
indicated in the 302 response. This will prevent that from happening and
return the 302 response to you, along with the redirect information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top