Created
March 8, 2010 02:38
-
-
Save tobbez/324792 to your computer and use it in GitHub Desktop.
Getting the target of an HTTP redirect in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string GetRedirectTarget(string url) | |
{ | |
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)WebRequest.Create(url); | |
request.AllowAutoRedirect = false; | |
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse(); | |
return response.Headers.Get("Location"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment