Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
379 views
in Technique[技术] by (71.8m points)

c# - ASP.NET page 'Page_Load' firing before Master Page's 'Page_Load' event?

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.

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.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...