ASP.NET页面母版页“的Page_Load”事件之前“的Page_Load”射击? [英] ASP.NET page 'Page_Load' firing before Master Page's 'Page_Load' event?

查看:110
本文介绍了ASP.NET页面母版页“的Page_Load”事件之前“的Page_Load”射击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的母版页,我有检查,看看用户是否登录,并将其重定向到如果不登录页面的的Page_Load 事件一点方法。

On my Master Page, I have a little method in the Page_Load event that checks to see if a user is logged in, and redirects them to the Login page if not.

问题是,我的一些页面的的Page_Load 事件presume记录一个用户在和这些事件似乎在登录检查之前解雇母版页,这会导致错误。

The problem is that for some of my pages the Page_Load events presume a users logged are in, and these events seems to fire before the login check in the master page, which causes errors.

什么是解决这个的一些方法?我可以用比其他的Page_Load在我的网页的任何事件,那会火的之后的母版页?

What are some ways around this? Any events I can use other than Page_Load in my pages, that'll fire after the master page?

推荐答案

您有丰富的页面周期,有很多事件的使用。
也许你可以使用 Page_Init 来检查,如果用户登录在母版页。
或者使用 Page_ preRender 中的其他页面。

You have a rich Page Cycle with lots of events to use. Perhaps you could use Page_Init to check if the user is logged-in in the Master Page. Or use Page_PreRender in the other pages.

这篇关于ASP.NET页面母版页“的Page_Load”事件之前“的Page_Load”射击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆