_PageStart.cshtml vs _AppStart.cshtml in ASP.NET WebPages
Asked Answered
C

1

7

What is the difference between _PageStart.cshtml vs _AppStart.cshtml? Can I use them interchangeably?

Checkoff answered 13/1, 2012 at 4:37 Comment(0)
C
21

_AppStart.cshtml is executed once when the application first starts. It is the place for setting global variables, or configuring email etc. _PageStart.cshtml executes every time a page in the same or lower level folder is requested. It is the place for performing per-request processing, such as setting layout pages or denying access to a folder to unauthenticated users.

See this article at the Microsoft Web Pages site.

Since they execute at different times in the application's lifecycle, it's difficult to see how they can be used interchangeably, whatever you mean by that.

Carty answered 13/1, 2012 at 6:13 Comment(1)
I thought they're the same. Thanks!Checkoff

© 2022 - 2024 — McMap. All rights reserved.