/// <summary> /// Fetches the URL. /// </summary> /// <returns>The webresponse object.</returns> public SimpleWebResponse FetchUrl() { if (IsValidUrl(this.RequestUrl)) { try { String htmlCode = ""; try { this.Request = WebRequest.Create(this.RequestUrl); this.Response = this.Request.GetResponse(); } catch (WebException e) { logger.Error("WebException ({0}) occured when fetching the url: {1}", e.Message, this.RequestUrl); this.Response = e.Response; } StreamReader sr = new StreamReader(this.Response.GetResponseStream()); htmlCode = sr.ReadToEnd(); SimpleWebResponse swr = new SimpleWebResponse(this.RequestUrl, this.RequestUrl, htmlCode); return swr; } catch (Exception e) { logger.Error("Exception ({1}) occured, when creating request for url: {0}", this.RequestUrl, e.Message); throw new ArgumentException(String.Format("The Url: {0} could not be fetched.", this.RequestUrl)); } } else { throw new ArgumentException(String.Format("The provided url did not match the specified format for html-urls: {0}", this.RequestUrl)); } }
public void DisplayWebPage(SimpleWebResponse response) { foreach (TabPage page in this.webSitesTabControl.TabPages) { if (page.Name.Equals(response.Url)) { MethodInvoker uiDelegate = delegate { page.Controls[0].Text = response.Html; page.Text = response.Title; }; UpdateUI(uiDelegate); } } }