Created
July 9, 2015 19:59
-
-
Save angelovstanton/e5777c266061758d0792 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class WebRequestRedirectStrategy : IRedirectStrategy | |
{ | |
public void Initialize() | |
{ | |
} | |
public string NavigateToFromUrl(string fromUrl) | |
{ | |
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(fromUrl); | |
request.Method = "HEAD"; | |
request.Timeout = (int)TimeSpan.FromHours(1).TotalMilliseconds; | |
string currentSitesUrl = string.Empty; | |
try | |
{ | |
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) | |
{ | |
currentSitesUrl = response.ResponseUri.ToString(); | |
} | |
} | |
catch (WebException) | |
{ | |
currentSitesUrl = null; | |
} | |
return currentSitesUrl; | |
} | |
public void Dispose() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment