protected void Page_Load(object sender, EventArgs e) { string finalHtml = ""; string urls = ""; string pager = @" <div style=""page-break-after: always;""></div>"; string[] ProcInstIDArr = Context.Request["ProcInstID"].Substring(0, Context.Request["ProcInstID"].ToString().Length - 1).Split(','); string[] ProcName = Context.Request["ProcName"].Substring(0, Context.Request["ProcName"].ToString().Length - 1).Split(','); for (int i = 0; i < ProcInstIDArr.Length; i++) { string procName = ProcName[i].ToString(); string procInstId = ProcInstIDArr[i].ToString(); urls = GetPrintPageList(urls, procName, procInstId); } finalHtml = GetFinalHtml(finalHtml, urls, pager); Context.Response.Write(finalHtml); Context.Response.Flush(); Context.Response.End(); } private static string GetFinalHtml(string finalHtml, string urls, string pager) { string[] arrUrl = urls.Split(','); string webString = ConfigurationManager.AppSettings["webString"]; for (int i = 0; i < arrUrl.Length; ++i) { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(webString + arrUrl[i]); req.Method = "GET"; req.ContentType = "application/x-www-form-urlencoded"; req.Timeout = 30000; HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); StreamReader reader = new System.IO.StreamReader(resp.GetResponseStream()); string html = reader.ReadToEnd(); if (i == 0) { MatchCollection matchs = Regex.Matches(html, @"(.*?)<form", RegexOptions.Singleline); foreach (Match m in matchs) { finalHtml += m.Value; } finalHtml = finalHtml.Replace("<form", ""); } else { finalHtml += pager; } MatchCollection matchsForm = Regex.Matches(html, @"<form(.*?)</form>", RegexOptions.Singleline); foreach (Match m in matchsForm) { finalHtml += m.Value; } } finalHtml += @" </body> <html>"; finalHtml = finalHtml.Replace("id=\"form1\"", "").Replace("<p style=\"height:90px;\"></p>", ""); return finalHtml; } private static string GetPrintPageList(string urls, string procName, string procInstId) { if (urls == "") { urls = "/Plugins/TravelInlandReimbursement/Page/PrintPage.aspx?step=view&procinstid=" + procInstId; } else { urls = urls + "," + "/Plugins/TravelInlandReimbursement/Page/PrintPage.aspx?step=view&procinstid=" + procInstId; } return urls; }