How to generate/output HTML file programatically

Bobby Ortega asked on May 14, 2015 02:56

Hi to all,

I'm able to generate pages programmatically using PortalEngine. I'd like to know how to generate/output HTML file instead/along side the ASPX pages programmatically. Any suggestions/inputs will be highly appreciated.

Thanks in advance.

Correct Answer

Charles Matvchuk answered on May 14, 2015 03:48

Not that I know of. If your really need it to do that, then you will have to write your own code, perhaps hook it up to Global Events which you can read up on in the documentation, as for the code perhaps you can find a library that would parse through and create a static html page. Remember Kentico dynamically creates pages with web parts and data, so to save it as static html really defeats the purpose.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on May 14, 2015 03:06

Not sure I or anyone else fully understands exactly what you're looking for. The page generated is HTML, do you want to allow a download of an HTML file or do you want just an HTML extension or what exactly do you mean?

0 votesVote for this answer Mark as a Correct answer

Bobby Ortega answered on May 14, 2015 03:14

Hi Sir Brenden Kehren,

Sorry if I was not clear enough. What I mean is, I'd like to generate an HTML file instead or along side of ASPX document if it is possible. We have a requirement of hosting the static HTML file outside Kentico CMS.

Thanks in advance.

0 votesVote for this answer Mark as a Correct answer

Charles Matvchuk answered on May 14, 2015 03:17

Not going to be easy if it consists of a design that has web parts and such in the portal engine. If you just want use the data that is stored in the Kentico database, just query the proper tables.

0 votesVote for this answer Mark as a Correct answer

Charles Matvchuk answered on May 14, 2015 03:19

Technically all output is HTML that is rendered in the browser.

0 votesVote for this answer Mark as a Correct answer

Bobby Ortega answered on May 14, 2015 03:37

Hi Charles Matvchuk,

Yes I agree. But is there any way that Kentico CMS can do File->Save-Page-As automatically through code to get the output static HTML?

Thanks in advance.

1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 14, 2015 13:21

If you want "HTML" files then simply change the extension to be .html vs. .aspx and in your browser when the page is rendered, do file>save as and it will have that extension already set for you. From within the CMS there is no way to click, select or export a page; it has to go through Kentico and IIS to be processed and then output.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.