private Uri ResolveBaseUrl() { Uri uri; try { var client = new RedirectedHttpClient(new Uri(Source)); uri = client.Uri; } catch (WebException ex) { var response = (HttpWebResponse)ex.Response; if (response == null) { throw; } uri = response.ResponseUri; } return(EnsureTrailingSlash(uri)); }
private string GetSafeRedirectedUri(string url) { try { Uri uri = new Uri(url); IWebProxy proxy = _cachedProxy; RedirectedHttpClient client = new RedirectedHttpClient(uri, proxy); return client.Uri.ToString(); } catch (WebException e) { if (WebExceptionStatus.Timeout == e.Status) { // rethrow the error because if ran into a timeout issue then // we don't want the code to continue as there is not going to be any good // result if we can't return a valid url to the caller. throw; } // we are assuming here that we just got a 403 - Forbidden: Access is denied error // because we are navigating to the publish url of the Gallery Server so we simply // catch the error and return the response url of the response that can be used for publishing // the reason why we get this error is because this is a POST action and IIS gives us this error // because it things that we are trying to navigate to a page. return e.Response.ResponseUri.ToString(); } }
private string GetSafeRedirectedUri(string url) { try { Uri uri = new Uri(url); IWebProxy proxy = _cachedProxy; RedirectedHttpClient client = new RedirectedHttpClient(uri, proxy); return(client.Uri.ToString()); } catch (WebException e) { if (WebExceptionStatus.Timeout == e.Status) { // rethrow the error because if ran into a timeout issue then // we don't want the code to continue as there is not going to be any good // result if we can't return a valid url to the caller. throw; } // we are assuming here that we just got a 403 - Forbidden: Access is denied error // because we are navigating to the publish url of the Gallery Server so we simply // catch the error and return the response url of the response that can be used for publishing // the reason why we get this error is because this is a POST action and IIS gives us this error // because it things that we are trying to navigate to a page. return(e.Response.ResponseUri.ToString()); } }
private Uri ResolveBaseUrl() { Uri uri = null; try { var client = new RedirectedHttpClient(new Uri(Source)); uri = client.Uri; } catch (WebException ex) { var response = (HttpWebResponse)ex.Response; if (response == null) { throw; } uri = response.ResponseUri; } return EnsureTrailingSlash(uri); }
private DataServicePackageRepository GetPackageRepository() { if (_packageRepository == null || _packageRepository.Source != _redirectedlPackageSource) { try { Uri packageUri = new Uri(PackageSource); IWebProxy packageSourceProxy = _proxyService.GetProxy(packageUri); IHttpClient packageSourceClient = new RedirectedHttpClient(packageUri, packageSourceProxy); _packageRepository = new DataServicePackageRepository(packageSourceClient); _redirectedlPackageSource = _packageRepository.Source; } catch (Exception) { _packageRepository = null; } } return _packageRepository; }