Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Static ASP.net Pages from entries in database?

Status
Not open for further replies.

cjtaylor

Programmer
Aug 12, 2001
69
US
Hello.

Instead of having one page that is dynamically updated from the database, I was wondering if it is possible to create a static page from each entry in my database. How should I approach this?

Thanks
Chris Taylor
 
You could create a file using a streamwriter and save it as a static page - I can't see why you ever need to do this though!

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
This method is actually quite useful for Content Management websites.

It makes it easier to track your traffic when you have separate actual static files out there. It also is more friendly to search engines.

Personally, I have a .template file that I use as (guess what!) a template, which just defines the page in terms of user controls.
Code:
<%@ Page %>
<head>
...
</head>
<body>
  <form>
    <uc:header pageID= />
    <uc:menu pageID= />
    <uc:content pageID= />
    <uc:footer pageID= />
  </form>
</body>
Just as a for instance (yours will surely be much more complicated than that), then read it in using a streamreader, replace "pageID=" w/ "pageID=thePageID" (along with any other stuff, keywords, titles, etc... that you need), and then as ca8msm said, use a streamwriter to write it back out to the disk.

Most of the content (in my case) is still stored solely in the database, and pulled on demand, but you could use the same method to write out the whole page statically if you wished (It would be overkill for my purposes, but you may have your reasons).

good luck.

-paul

penny.gif
penny.gif

The answer to getting answered -- faq855-2992
 
It makes it easier to track your traffic when you have separate actual static files out there. It also is more friendly to search engines.
Good Point - hadn't really thought about it in terms of search engines/traffic.


----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
You could also explore storing XML and XSLT to create your pages.
Years back we stored static HTML in files and had CGI scripts in PERL reading the files and displaying the web pages.
Marty
 
Thanks for all your input.

I am writing a link index program similar this one and noticed that all their pages are actually static pages and search engines love static pages.

Thanks again
Chris
 
You may want to look into SQL templates also....seems I remember something about SQL generating HTML pages filling them with data.

Bassguy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top