Most server side code are written inside individual web pages. For example, if a web page contains an input form, the web page typically contains server code for reading the data.
However, by creating a page named _AppStart in the root of your site, you can have startup code executed before the site starts. If this page exists, ASP.NET runs it the first time any page in the site is requested.
Typical use for _AppStart is startup code and initialization of global values like counters and global names.
Note 1: _AppStart should have the same file extension as your web pages, like: _AppStart.cshtml.
Note 2: _AppStart has an underscore prefix. Because of this, the files cannot be browsed directly.
Practice Excercise Practice now