Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2006, 06:58 PM
Authorized User
 
Join Date: Apr 2005
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default Checking for existing object

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?
 
Old February 14th, 2006, 07:18 PM
Wrox Technical Editor
 
Join Date: Dec 2005
Posts: 271
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Existing Components Thami SQL Server 2005 0 August 8th, 2008 02:51 AM
Serializing object into existing XmlTextWriter planoie .NET Framework 2.0 0 October 15th, 2007 09:54 AM
Object Existing moedev Access 3 April 12th, 2006 02:48 PM
Adding existing and non-existing attributes spencer.clark XSLT 5 July 27th, 2005 04:02 PM
Is there any way to close all existing connections jojys Classic ASP Databases 1 October 20th, 2004 09:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.