Getting the location from a WebClient on a HTTP 302 Redirect?

Posted by Michael Stum on Stack Overflow See other posts from Stack Overflow or by Michael Stum
Published on 2010-04-08T22:15:52Z Indexed on 2010/04/08 22:23 UTC
Read the original article Hit count: 266

Filed under:
|
|
|
|

I have a URL that returns a HTTP 302 redirect, and I would like to get the URL it redirects to.

The problem is that System.Net.WebClient seems to actually follow it, which is bad. HttpWebRequest seems to do the same.

Is there a way to make a simple HTTP Request and get back the target Location without the WebClient following it?

I'm tempted to do raw socket communication as HTTP is simple enough, but the site uses HTTPS and I don't want to do the Handshaking.

At the end, I don't care which class I use, I just don't want it to follow HTTP 302 Redirects :)

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#