Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created July 9, 2015 19:59
Show Gist options
  • Save angelovstanton/e5777c266061758d0792 to your computer and use it in GitHub Desktop.
Save angelovstanton/e5777c266061758d0792 to your computer and use it in GitHub Desktop.
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