First, declare that the generation of this static page is the result of Eric's hard work: EFPLatform. CodeGenerator. Thank you, Eric !!
There are many different implementation methods for static page generation and many factors. It is the best for you. You don't have to say anything here. After a static page is generated, other problems arise, such as generating a static page, adding an access count after the page is generated, and adding a comment asynchronously. With Eric brother, there is no need to repeat how to generate static pages here.
The following describes the issues that arise after the static page is generated:
Due to space limitations, two small modules will be introduced this time: 1. Increase access count 2. Generate the homepage
1. Add the access count for the generated static page:
My approach is to create a dynamic page that increases the reference count. This page accepts the parameters and then adds the access count according to the parameters. Use <script src = "/Module_News/Increase. aspx? Id = ID No. "type =" text/javascript "> </script>
Call this page to increase the access count
Cs code:
1if (! This. IsPostBack)
2 {
3 if (Request. QueryString ["id"]! = Null)
4 {
5 Module_News mnMain = new Module_News ();
6 mnMain. Module_News_FluxIncrease (Request. QueryString ["id"]. ToString ());
7 // Response. Redirect (string. Format (@ "/Html/News/3/other 02.16.html", Request. QueryString ["code"]. ToString ()));
8}
9 else
10 {
11 Response. Write ("the data you requested does not exist ");
12}
13}
Note: The page element is empty. You can also change it to an ashx file.
2. generate static pages on the home page
I used cache for the homepage. However, limited by its own technical level, the cache effect is not ideal. I do not know why some links on the home page still fail. Therefore, we decided to replace the cache with static pages. I didn't use templates to generate static homepage pages here. After all, there are too many things on the homepage, which is too complicated.
Here we take a coincidence and rewrite Render:
Code:
1 protected override void Render (HtmlTextWriter writer)
2 {
3 System. IO. StringWriter html = new System. IO. StringWriter ();
4 System. Web. UI. HtmlTextWriter tw = new HtmlTextWriter (html );
5 base. Render (tw );
6 System. IO. StreamWriter sw = new System. IO. StreamWriter (Server. MapPath ("index.html"), false, System. Text. Encoding. Default );
7 sw. Write (html. ToString ());
8 sw. Close ();
9 tw. Close ();
10 // Response. Write ("page generation successful! ");
11}
Okay, the page is generated, and the problem arises again. How can this problem be updated? Is it generated every time, or is there an update to regenerate...
My approach is to allow users to update themselves. Add the following to the page:
<Script language = "javascript" type = "text/javascript">
// Request Default. aspx and call Render to regenerate the static homepage page
Document. write ('<script type = "text/javascript" src = "/Default. aspx"> <' + '/script> ');
</Script>
In this way, the user calls the home page once to access the generated static page, and then regenerate the static page.