<p>We're building a CMS. The site will be built and managed by the users in aspx pages, but we would like to create a static site of HTML's. 
The way we're doing it now is with code I found <a href="http://forums.asp.net/p/931180/1092188.aspx#1092188" rel="nofollow noreferrer">here</a> that overloads the Render method in the Aspx Page and writes the HTML string to a file. This works fine for a single page, but the thing with our CMS is that we want to automatically create a few HTML pages for a site right from the start, even before the creator has edited anything in the system.
Does anyone know of any way to do this?</p>

[{'answer_id': 56281, 'author': 'Frank Krueger', 'author_id': 338, 'author_profile': 'https://Stackoverflow.com/users/338', 'pm_score': 3, 'selected': True, 'text': '<p>Calling the <code>Render</code> method is still pretty simple. Just create an instance of your page, create a stub <code>WebContext</code> along with the <code>WebRequest</code> object, and call the <code>Render</code> method of the page. You are then free to do whatever you want with the results.</p>\n\n<p>Alternatively, write a little <code>curl</code> or <code>wget</code> script to download and store whichever pages you want to make static.</p>\n'}, {'answer_id': 56294, 'author': 'ckarras', 'author_id': 5688, 'author_profile': 'https://Stackoverflow.com/users/5688', 'pm_score': 2, 'selected': False, 'text': '<p>You could use wget (a command line tool) to recursively query each page and save them to html files. It would update all necessary links in the resulting html to reference .html files instead of .aspx. This way, you can code all your site as if you were using server-generated pages (easier to test), and then convert it to static pages.</p>\n\n<p>If you need static HTML for performance reasons only, my preference would be to use ASP.Net output caching.</p>\n'}, {'answer_id': 56307, 'author': 'jttraino', 'author_id': 3203, 'author_profile': 'https://Stackoverflow.com/users/3203', 'pm_score': 2, 'selected': False, 'text': '<p>I recommend you do this a very simple way and don\'t do it in code.  It will allow your CMS code to do what the CMS code should do and will keep it as simple as possible.</p>\n\n<p>Use a product such as <a href="http://www.httrack.com/" rel="nofollow noreferrer">HTTrack</a>.  It calls itself a "website copier".  It crawls a site and creates html output.  It is fast and free.  You can just have it run at whatever frequency you think is best.</p>\n\n<p>It decouples your HTML output needs from your CMS design and implementation.  It reduces complexity and gives you some flexibility in how you output the HTML without introducing failure points in your CMS code.</p>\n'}, {'answer_id': 56399, 'author': 'Lea Cohen', 'author_id': 278, 'author_profile': 'https://Stackoverflow.com/users/278', 'pm_score': 1, 'selected': False, 'text': '<p>@ckarras: I would rather not use an external tool, because I want the HTML pages to be created programmatically and not manually.</p>\n\n<p>@jttraino: I don\'t have a time interval in which the site needs to be outputted- the uotput has to occur when a user creates a new site.</p>\n\n<p>@Frank Krueger: I don\'t really understand how to create an instance of my page using WebContext and WebRequest. </p>\n\n<p>I searched for "wget" in <a href="http://www.searchdotnet.com" rel="nofollow noreferrer">searchdotnet</a>, and got to <a href="http://forums.asp.net/p/540670/540744.aspx#540744" rel="nofollow noreferrer">a post</a> about a .net class called WebClient. It seems to do what I want if I use the DownloadString() method - gets a string from a specific url. The problem is that because our CMS needs to be logged in to, when the method tries to reach the page it\'s thrown to the login page, and therefore returns the login.aspx HTML...</p>\n\n<p>Any thoughts as to how I can continue from here?</p>\n'}, {'answer_id': 66312, 'author': 'Lea Cohen', 'author_id': 278, 'author_profile': 'https://Stackoverflow.com/users/278', 'pm_score': 2, 'selected': False, 'text': '<p>I seem to have found the solution for my problemby using the Server.Ecxcute method.</p>\n\n<p>I found an <a href="http://odetocode.com/articles/162.aspx" rel="nofollow noreferrer">article</a> that demonstared the use of it:</p>\n\n<pre><code>TextWriter textWriter = new StringWriter();\nServer.Execute("myOtherPage.aspx", textWriter);\n</code></pre>\n\n<p>Then I do a few maniulatons on the textWriter, and insert it into an html file. Et voila! It works!</p>\n'}]
['https://Stackoverflow.com/questions/56279', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/278/']