Friday, 15 January 2010

c# - Find requested page from masterpage load? -



c# - Find requested page from masterpage load? -

say in masterpage load event. if user logged in, need redirect them away login.aspx, if not logged in, need redirect them login.aspx. first, need know page trying access.

how can information?

thanks

so create base of operations class pages , in class override oninit (eventargs e) method. in method, set code checks whether user signed on scheme (by checking session variable representing user not null) , if variable null redirect login page. if follow approach, content pages (except login page) must inherit base of operations class.

i hope helps you.

public class basepage : page { /// <summary> /// /// </summary> /// <param name="e"></param> protected override void oninit(eventargs e) { if (session["usuario"] == null) { response.redirect(resolveclienturl("~/login.aspx")); } } }

c# asp.net

No comments:

Post a Comment