title: how to get current page source from asp.net aspx page
body: <p>Hi, I am trying to get the current page source by using the asp.net application. I found a piece of code which converts html to pdf but in order to convert my page to pdf I need to get the html code of the page. How can I get these as a string? My simple code is like this:</p>
  
  <pre><code>        string sPathToWritePdfTo = Server.MapPath("") + "/pdf_dosya_adi.pdf";
  
          System.Text.StringBuilder sbHtml = new System.Text.StringBuilder();
          sbHtml.Append("&lt;html&gt;");
          sbHtml.Append("&lt;body&gt;");
          sbHtml.Append("&lt;font size='14'&gt;HTML den PDF çevirme Test&lt;/font&gt;");
          sbHtml.Append("&lt;br /&gt;");
          sbHtml.Append("Body kısmında yazacak yazı");
          sbHtml.Append("&lt;/body&gt;");
          sbHtml.Append("&lt;/html&gt;");
  
          using (System.IO.Stream stream = new System.IO.FileStream
  
          (sPathToWritePdfTo, System.IO.FileMode.OpenOrCreate))
          {
              Pdfizer.HtmlToPdfConverter htmlToPdf = new Pdfizer.HtmlToPdfConverter();
              htmlToPdf.Open(stream);
              htmlToPdf.Run(sbHtml.ToString());
              htmlToPdf.Close();
          }
          HttpContext.Current.Response.Clear();
          HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "friendlypdfname.pdf"));
          HttpContext.Current.Response.ContentType = "application/pdf";
  
          HttpContext.Current.Response.WriteFile(sPathToWritePdfTo);
          HttpContext.Current.Response.End();
  </code></pre>
  
  <p>If I can get the html code off my asp.net page I put all line of my page into the 
   sbHtml.Append("");
  code by using a for loop and this will solve my problem in my opinion.</p>