Determine a session variable type

Discussion in 'ASP .Net' started by tshad, Feb 20, 2006.

  1. tshad

    tshad Guest

    I have some code to go through a session collection for my error page
    routine and I get an error on my objects that I store in session variables.

    Dim strName as String
    Dim iLoop as Integer

    For Each strName in Session.Contents
    trace.warn(strName & " - " & Session.Contents(strName))
    Next

    How do I determine what the variable type of each session variable is? I
    get an error if I try to print the contents of a non-scalar object (of
    course).

    In a trace window MS lists the type and the value. If not a scalar type it
    just puts the variable type in the value field. Such as:

    EmailHtml System.Boolean False
    CompanyID System.Int64 1000
    User RolesBasedAuthentication.User
    RolesBasedAuthentication.User

    I need to do something like this.

    Thanks,

    Tom
     
    tshad, Feb 20, 2006
    #1
    1. Advertising

  2. Hello Tshad,

    I would think you could use Session["var1"].GetType()
    or Session.Contents["var1"].GetType();
    --
    brians
    http://www.limbertech.com


    "tshad" wrote:

    > I have some code to go through a session collection for my error page
    > routine and I get an error on my objects that I store in session variables.
    >
    > Dim strName as String
    > Dim iLoop as Integer
    >
    > For Each strName in Session.Contents
    > trace.warn(strName & " - " & Session.Contents(strName))
    > Next
    >
    > How do I determine what the variable type of each session variable is? I
    > get an error if I try to print the contents of a non-scalar object (of
    > course).
    >
    > In a trace window MS lists the type and the value. If not a scalar type it
    > just puts the variable type in the value field. Such as:
    >
    > EmailHtml System.Boolean False
    > CompanyID System.Int64 1000
    > User RolesBasedAuthentication.User
    > RolesBasedAuthentication.User
    >
    > I need to do something like this.
    >
    > Thanks,
    >
    > Tom
    >
    >
    >
     
    =?Utf-8?B?YnJpYW5zW01DU0Rd?=, Feb 20, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shapper
    Replies:
    4
    Views:
    33,191
  2. Gernot Frisch

    how to determine type-type?

    Gernot Frisch, Jan 12, 2005, in forum: C++
    Replies:
    3
    Views:
    406
    Ulrich Achleitner
    Jan 13, 2005
  3. Replies:
    4
    Views:
    446
    Magnus Lycka
    Aug 19, 2005
  4. Walter L. Preuninger II

    Way to determine type of variable?

    Walter L. Preuninger II, Jul 16, 2004, in forum: C Programming
    Replies:
    21
    Views:
    574
    Kenny McCormack
    Jul 17, 2004
  5. chowchho
    Replies:
    7
    Views:
    659
    Patrice
    Mar 28, 2008
Loading...

Share This Page