Subject: Checking for existing object
Posted By: Quick209 Post Date: 2/14/2006 5:58:25 PM
Hey all, I did not know what specifically this would fall under but it is using C# in general.  I have a question with something that has been puzzling me for awhile now so I find other methods to do it but now I want to do this method.  To put it simply, is there a command in C# to check to see if an object exists. I would like to check to see if a variable was created before creating one.  The real reason for this is for Sessions on my asp.net page.  I would like to see if a session is out there before modifying or creating one.  Anyone know of a way to do this?
Reply By: adam_kahtava Reply Date: 2/14/2006 6:18:00 PM
I'm not sure if this is what your looking for, but....

Here's an ASP.NET solution for detecting an ASP.NET Session Timeout: http://aspalliance.com/520
See the URL for further explanation.

public class basePageSessionExpire : System.Web.UI.Page{
   public basePageSessionExpire(){}
   override protected void OnInit(EventArgs e){
      base.OnInit(e);
      if (Context.Session != null){
         if (Session.IsNewSession){
            string szCookieHeader = Request.Headers["Cookie"];
            if ((null != szCookieHeader) && (szCookieHeader.IndexOf("ASP.NET_SessionId") >= 0)){
               Response.Redirect("sessionTimeout.htm");
            }  
         }
      }
   }
}

- A.Kahtava

Go to topic 40027

Return to index page 369
Return to index page 368
Return to index page 367
Return to index page 366
Return to index page 365
Return to index page 364
Return to index page 363
Return to index page 362
Return to index page 361
Return to index page 360