Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9308141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:33:30+00:00 2026-06-19T00:33:30+00:00

I am attempting to load a parsed aspx file into a string. The reason

  • 0

I am attempting to load a parsed aspx file into a string. The reason for this is because I have a page with a fair amount of html on it which also has sections that need to be processed in order to insert the correct information. This page then needs to be displayed as a confirmation page as well sent in a confirmation email when the user submits a form.

Displaying the confirmation page is simple enough, but my idea to prevent code duplication is to render the aspx file to a string variable to use as the content of the email as well.

I realize that I could add all the content as a huge multi-line string and load it onto the aspx page, and then into the email, but this solution feels messy to me and will require an application re-compile should I ever want to change the content.

Perhaps somebody can suggest a better way to achieve what I am attempting?

The code I have come up with is below, but I am nit sure if it is possible to somehow catch the output from ProcessRequest before it gets sent to the browser:

IHttpHandler handler = PageParser.GetCompiledPageInstance("/SubmitConfirmation.aspx?appid=" + this.Id, "SubmitConfirmation.aspx", HttpContext.Current);
handler.ProcessRequest(HttpContext.Current);
string str_out = ???;

Basically what I am trying to achieve is the same as the following PHP code would do:

<?php
ob_start();
include("SubmitConfirmation.php");
$str_out = ob_get_contents();
ob_end_clean();
?>

Any suggestions are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T00:33:31+00:00Added an answer on June 19, 2026 at 12:33 am

    Did you try

    System.IO.StringWriter htmlStringWriter = new System.IO.StringWriter();
    Server.Execute("Page.aspx", htmlStringWriter);
    string htmlOutput = htmlStringWriter.GetStringBuilder().ToString();
    

    found on Kiyoshi’s blog. Tested it – and worked for me. See MSDN, too

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html string I'd like to dump directly into an element. This
I have a log file that I want to parse and load into a
I'm attempting to load a scene from a file into Three.js (custom format, not
Im attempting to load a hex literal from an xml settings file, I can
I am attempting to load some images into a very basic C++/SDL based program.
I'm attempting to just change the background colour of a webpage upon page load.
I'm attempting to load a store catalog into MongoDb (2.2.2) using Node.js (0.8.18) and
I'm attempting to parse load a rather complicated XML schema into a Schema object
I'm attempting to parse an XML file using simpleXML, but I keep running into
I am attempting to load JSON content into a listview containing image and text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.