www.webdeveloper.com
Results 1 to 3 of 3

Thread: ASP.Net storing objects in session state

  1. #1
    Join Date
    Nov 2005
    Posts
    41

    ASP.Net storing objects in session state

    Hi,

    How do I check if an ASP.net session contains a particular variable or not? I want to do something like this.

    Code:
    if Session("user") <> "" Then
     '... do something here...
    End if
    I do not know the type of the data that is stored in Session("user"). I just want to know if anything has been assigned to it.

    The above causes an error:

    Overload resolution failed because no Public '<>' can be called with these arguments:
    'Public Shared Operator <>(a As String, b As String) As Boolean':
    Argument matching parameter 'a' cannot convert from 'SchedulerUser' to 'String'.

    I hope someone can help!

  2. #2
    Join Date
    Sep 2004
    Location
    Northeast, FL
    Posts
    332
    Code:
    If Session("user") IsNot Nothing Then
        'Do something.
    End If

  3. #3
    Join Date
    Apr 2007
    Posts
    24
    Code:
    IF not Session("user") = String.Empty THEN
     do something
    END IF
    Even if the Session isn't yet created, it'll always throw a String.Empty

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles