protected void Page_Load(object sender, EventArgs e) { EnableViewState = false; try { if (Request.QueryString.Count == 2 && Request.QueryString.AllKeys[0] == "discoveryID" && Request.QueryString.AllKeys[1] == "absoluteUri") { ArachnodeDataSet.WebPagesRow webPagesRow = ArachnodeDAO.GetWebPage(Request.QueryString["discoveryID"]); if (webPagesRow != null) { string source = null; if (webPagesRow.Source == null || webPagesRow.Source.Length == 0) { string discoveryPath = DiscoveryManager.GetDiscoveryPath(ApplicationSettings.DownloadedWebPagesDirectory, webPagesRow.AbsoluteUri, webPagesRow.FullTextIndexType); if (File.Exists(discoveryPath)) { source = File.ReadAllText(discoveryPath, Encoding.GetEncoding(webPagesRow.CodePage)); } else { uxLblException.Text = "The WebPage source was not found in the database or on disk."; uxLblException.Visible = true; return; } } else { source = Encoding.GetEncoding(webPagesRow.CodePage).GetString(webPagesRow.Source); } //Request.Url.Scheme + "://" + Request.Url.Authority //ANODET: Should this be a configuration setting? Perhaps - hotlinking isn't exactly polite, but does provide the best user experience. (Version 1.5) uxLWebPage.Text = HtmlManager.CreateHtmlDocument(webPagesRow.AbsoluteUri, webPagesRow.FullTextIndexType, source, UriQualificationType.AbsoluteWhenDownloadedDiscoveryIsUnavailable, ArachnodeDAO, true).DocumentNode.OuterHtml; } else { uxLblException.Text = "The WebPage was not found in the database."; uxLblException.Visible = true; } } } catch (Exception exception) { uxLblException.Text = exception.Message; uxLblException.Visible = true; ArachnodeDAO.InsertException(null, null, exception, false); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name = "sender">The source of the event.</param> /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { EnableViewState = false; try { if (Request.QueryString.Count == 5 && Request.QueryString.AllKeys[0] == "discoveryID" && Request.QueryString.AllKeys[1] == "absoluteUri" && Request.QueryString.AllKeys[2] == "webPage" && Request.QueryString.AllKeys[3] == "codePage" && Request.QueryString.AllKeys[4] == "fullTextIndexType") { string source = null; if (File.Exists(Encryption.DecryptRijndaelManaged(Request.QueryString["webPage"]))) { source = File.ReadAllText(Encryption.DecryptRijndaelManaged(Request.QueryString["webPage"]), Encoding.GetEncoding(int.Parse(Request.QueryString["codePage"]))); } else { ArachnodeDataSet.WebPagesRow webPagesRow = ArachnodeDAO.GetWebPage(Request.QueryString["discoveryID"]); if (webPagesRow != null && webPagesRow.Source.Length != 0) { source = Encoding.GetEncoding(webPagesRow.CodePage).GetString(webPagesRow.Source); } } if (source != null) { //ANODET: Should this be a configuration setting? Perhaps - hotlinking isn't exactly polite, but does provide the best user experience. (Version 1.5) uxLWebPage.Text = HtmlManager.CreateHtmlDocument(Request.QueryString["absoluteUri"], Request.QueryString["fullTextIndexType"], source, UriQualificationType.AbsoluteWhenDownloadedDiscoveryIsUnavailable, ArachnodeDAO, false).DocumentNode.OuterHtml; } else { uxLWebPage.Text = "The WebPage source was not found in the database or on disk."; try { throw new Exception("The WebPage source for " + HttpUtility.UrlDecode(Request.QueryString["absoluteUri"]) + " was not found in the database or on disk."); } catch (Exception exception) { ArachnodeDAO.InsertException(null, null, exception, false); } } } } catch (Exception exception) { ArachnodeDAO.InsertException(null, null, exception, false); } }