Tag: page init

在页面加载之前检查会话变量和重定向到登录页面

如何在使用ASP.NET加载页面之前检查变量并重定向到另一个页面? 我知道生命周期,而PageInit()听起来似乎是正确的,但我似乎无法在Visual Studio中找到没有和错误的代码。 我不能把onpageinit=””放在我的页面声明的第一行。 我想把它放在不同的地方吗? 我的页面声明如下: 这是我想在页面加载上运行的代码: // Check if the user is logged in, if not send them to the login page if (session.logged_in == false) { // Redirect the user to the login page Response.Redirect(“login.aspx”); }