This chapter describes global pages AppStart and Pagestart.
Before the Web starts: _appstart
Most of the server-side code is written on the personal page. For example, if the page contains an input form, the page typically contains server-side code to read the form data.
However, you can start code execution before the site starts by creating a page named _appstart under your site's root directory. If this page is present, ASP. NET will run this page first when other pages in the site are requested.
The typical use of _appstart is to start code and initialize global values (such as counters and global names).
Note 1:_appstart has the same file name extension as your Web page, such as: _appstart.cshtml.
Note The 2:_appstart has an underscore prefix. Therefore, these files cannot be browsed directly.
Before each page: _pagestart
Just as _appstart runs before your site starts, you can write code that runs before any page in each folder.
For each folder in your site, you can add a file named _pagestart.
How does it work?
Shows how it works:
When a request is received, ASP. NET first checks to see if the _appstart exists. If _appstart exists and this is the first request received by the site, run _appstart.
Then ASP. NET checks if the _pagestart exists. If _pagestart exists, run _pagestart before the other requested page runs.
You can call Runpage () in _pagestart to specify where the requested page will run. Otherwise, by default, the requested page is run after _pagestart is run.
"Recommended"
1. ASP. NET free Video Tutorials
2. Share the ASP. NET Learning Notes (1)--webpages Razor
3. Share the ASP. NET Learning Notes (2)--webpages Introduction
4. Share the ASP. NET Learning Notes (3) Webpages layout
5. Share the ASP. NET Learning Notes (4) folder