How to have a single "HelperClass.IsLoggedIn()" method for the entire ASP.NET web project? -


This is a general requirement on every page:

  if (session ["login" Done "" == faucet || (Bull) session ["login in"] = true)) .... user is not logged in. Return  

I think There was a way, I can make a class "helper" with a method signature bool IsLoggedIn () and it can automatically check that method by calling a page. Whether it was called from the page in which session ["Logged in"] is set to true something like this:

  class helper {public child islamgden () {System.Web .UI.Page page = *** FindCallerPageSomeHow *** (); if (page session ["logged in"] == faucet || ((Bull) page session ["login in"]! = True ) Return return; return (bool) page. Hpptt session ["login in"] == true);}}  

Of course, I have an interface for each codebehind class I can try to implement it, but it is repetitive. Besides, I could go through HttpContext for IsLoggedIn , but it is a bit disorganized ..

Any ideas? Is there a simple-implementation pattern for this?

You can always have a stable class in the library somewhere, but my favorite technique is just your own Creating a page class and adding properties or override events over there.

  public class myPage: System.Web.UI.Page {public zero myPage () {} public child's isogidine () {System.Web.UI.Page page = *** SearchColorPage page ** * (); If (page session ["login in"] == faucet || ((bool) page session ["login in"] = true)) return; Return (bool) page. Hpptt session ["login in"] == true); }}  

Then in the code behind your original page, you

  public partial myAspxPage: myNamespace.myPage {}  

For example, in my page class there is usually a valid property called ValuedUser which has the proper user information (so I do not have to keep looking at it). If that value is empty, then I do not have one. If it is not so, what do I need from me? However, whenever I create a new page in my site, I will have the rights to my page category instead of default.

EDIT: Your method has been added for a bit more clarity.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -