webmatrix – ASP.NET页面中的_PageStart.cshtml与_AppStart.cshtml

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

解决方法

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

See this article at the Microsoft Web Pages site.

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

相关文章

判断URL文件是不是在于在。private static bool UrlIsExist(...
由于在.net中,Request时出现有HTML或Javascript等字符串时,...
public static bool ProcessIdCard(this string idCard, out...
protected void Page_Load(object sender, EventArgs e){ Sc...