ASP.NET 网页中的 _PageStart.cshtml 与 _AppStart.cshtml

发布于 2024-12-26 07:17:23 字数 61 浏览 3 评论 0原文

_PageStart.cshtml 与 _AppStart.cshtml 有什么区别?我可以互换使用它们吗?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

许你一世情深 2025-01-02 07:17:23

_AppStart.cshtml 在应用程序首次启动时执行一次。它是设置全局变量或配置电子邮件等的地方。每次请求相同或较低级别文件夹中的页面时,_PageStart.cshtml 都会执行。它是执行每个请求处理的地方,例如设置布局页面或拒绝未经身份验证的用户访问文件夹。

请参阅 Microsoft 网站上的这篇文章页面站点

由于它们在应用程序生命周期的不同时间执行,因此很难看出它们如何可以互换使用,无论您的意思是什么。

_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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文