creating static pages (creating pages from data, and leaving them alone after that)

Discussion in 'C#' started by nubsii, May 16, 2008.

  1. #1
    How do you make static pages? In the past I'd just use some File.IO and write myself *.html pages... but I want a little more functionality this time..

    Here's what I'm trying to do:
    I have some articles which aren't ever going to change. Let's say there's 100 of them, and I don't want to have them all as article-name.aspx grouped together in my project. I'm gonna put them all into SQL like a normal person. But unlike a normal person, I'm not going to run a query and go get an article when someone wants to read it -- these articles aren't going to change and I want to generate them all upfront at once.

    Now to make things a little harder, I have a masterpage and I would like these articles to use the masterpage. Can I programatically create aspx files, would that work? (does asp.net wanting be a compiled app block my ability to do this?? aspx files are just text files right???)

    Any ideas would be appreciated :cool:
     
    nubsii, May 16, 2008 IP
  2. Jhar

    Jhar Peon

    Messages:
    318
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could create a "template" .aspx page with the look and feel you like, then use the System.IO.StreamReader class to read the file, then place the content into a string and pull in your desired content from the database and then write the string back out as a .aspx file using System.IO.StreamWriter class.
     
    Jhar, May 18, 2008 IP
  3. rkstech

    rkstech Active Member

    Messages:
    195
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    #3
    Sorry not sure of ASPX but I used this kind of things using File system object in ASP

    but creating Static HTML and naming them with the page Titles, that was for SEO
     
    rkstech, May 19, 2008 IP