Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Get HTML Output

How do I get the HTML output of another page using the PageData.GetPage method
Jun 17, 2008 14:00

Hi Alok!

It depends a little on what html your trying to get.

If its just the htmlcode entered for some property (for example "MainBody") on the other page, then it would be as simple as:

PageData otherPage = EPiServer.DataFactory.Instance.GetPage(otherPageRef);
string html = otherPage["MainBody"] as string;

But, if you want to get the "complete" htmlpage (as it would have been rendered by the aspx/ascx) it would be a little trickier. The easiest solution would be to simply issue a webrequest to the page and read the returned html response stream through a StringReader.

While this works, it has the downside of hitting the server with a new request which could be both time and resource consuming, especially on a site with lots of requests.

I have done some hacks around the PageParser.GetCompiledPageInstance() which lets you "shortcut" the request by calling into the IHttpHandler directly without the need to issue a "full" webrequest and also to capture the rendered html output.

I could probably dig out some sample code for you if youre interested, just drop me a email (johan.olofsson @

Johan Olofsson


Jun 17, 2008 14:18

If anyone's interested, I made a blog post (with sources) on how one can get a page's html without a "full" web request.


Jun 18, 2008 15:30
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.