tags:

views:

168

answers:

5

I have a process that will need to generate a lot of static html from a set of data. The html is relatively complex and I want the maintenance to be fairly simple so I don't want to embed much if any html in program code. At my company the blessed tool set is .net or php. My initial thought was to embed the asp.net compiler into the batch program and feed a generated page object the data it would need before rendering. The rendered output along with data would then be saved to disk. Does this sound feasible and should it be done? Another suggestion was to write a batch php script that wrote its output to the files. This sounds simpler but the skill set of the developers that will maintain the program aren't so strong in php. What other more simpler and elegant ways are there to render a reasonable amount of somewhat complicated html ahead of time?

+1  A: 

Depends on your data. You could also use xslt if data are from xml.

Aif
+2  A: 

This sounds daft, and there's bound to be a better way - but it would make the development/debugging fairly straightforward:

  • Write it as a normal ASP.NET site
  • The batch process is:
    • Start up Cassini (or even proper IIS)
    • Feed a load of URLs (and/or form data) into a tool such as wget or curl, and get them to save the results out

Another alternative might be to use LINQ to XML to "hand-generate" XHTML. It really depends on the format of your data etc.

Jon Skeet
Jon, "LINQ to XML to "hand-generate" XHTML" sounds very interesting. But i have no clue how to use LINQ to generate XHTML. I thought LINQ does query data, not generate some?
Marcel
@Marcel: LINQ to XML is really just an XML API which plays nicely with LINQ to Objects. It's the nicest XML API I've ever used.
Jon Skeet
A: 

Don't overcomplicate. You need a website, build a website.

Mike Robinson
A: 

For creating the web pages, I suggest using a template engine - I like Smarty, but there are plenty of others to choose from. This will make maintaining the pages easier.

If you keep or generate an index page, you can then use wget to turn all pages into static html.

Hugh Bothwell
+1  A: 

If you are worried about the performance of the html generation you should look into the caching abilities of asp.net.

Asp.net caching allows the generated html to be cached in memory so that the next request gets the html served without the page being generated. This will be almost as fast as generating regular html files.

With that said. Why don't you just set up a web site with regular html pages? IIS lets you mix aspx and html pages freely.

Rune Grimstad