Problem with Session.Contents

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cecil Westerhof

    Problem with Session.Contents

    I have the following code:

    for each SesVar in Session.Content s
    if( Session.Content s(SesVar) <> "" ) then

    The problem is that most of the time this works okay, but sometimes the code
    crashes on the compare. Anyone an idea what could be the problem?


  • Ray Costanzo [MVP]

    #2
    Re: Problem with Session.Content s

    Crashes? You mean that you are presented with an error message? What is
    that message?

    Ray at work

    "Cecil Westerhof" <someone@micros oft.com> wrote in message
    news:%23Td55pX0 EHA.3364@TK2MSF TNGP12.phx.gbl. ..[color=blue]
    >I have the following code:
    >
    > for each SesVar in Session.Content s
    > if( Session.Content s(SesVar) <> "" ) then
    >
    > The problem is that most of the time this works okay, but sometimes the
    > code crashes on the compare. Anyone an idea what could be the problem?
    >
    >[/color]


    Comment

    • Evertjan.

      #3
      Re: Problem with Session.Content s

      Cecil Westerhof wrote on 23 nov 2004 in
      microsoft.publi c.inetserver.as p.general:[color=blue]
      > for each SesVar in Session.Content s
      > if( Session.Content s(SesVar) <> "" ) then[/color]

      [you can do without the () in vbs]

      The variable value is in SesVar itself, so:

      for each SesVar in Session.Content s
      if SesVar <> "" then response.write SesVar & "<br>"
      next

      But then, Cecile,
      an empty session variable does not exist anyway,
      I think,
      so the whole action can be simplyfied to:

      for each SesVar in Session.Content s
      response.write SesVar & "<br>"
      next

      dacht je niet?

      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress,
      but let us keep the discussions in the newsgroup)

      Comment

      • Aaron [SQL Server MVP]

        #4
        Re: Problem with Session.Content s

        What does "crashes" mean? If it is type mismatch, then you might want to
        make sure you exclude any arrays or other complex data types/objects from
        your comparison. Please see http://www.aspfaq.com/2524

        --
        Please contact this domain's administrator as their DNS Made Easy services have expired.

        (Reverse address to reply.)




        "Cecil Westerhof" <someone@micros oft.com> wrote in message
        news:#Td55pX0EH A.3364@TK2MSFTN GP12.phx.gbl...[color=blue]
        > I have the following code:
        >
        > for each SesVar in Session.Content s
        > if( Session.Content s(SesVar) <> "" ) then
        >
        > The problem is that most of the time this works okay, but sometimes the[/color]
        code[color=blue]
        > crashes on the compare. Anyone an idea what could be the problem?
        >
        >[/color]


        Comment

        • Cecil Westerhof

          #5
          Re: Problem with Session.Content s

          "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
          news:Xns95AAB56 CA31A1eejj99@19 4.109.133.29...[color=blue]
          > Cecil Westerhof wrote on 23 nov 2004 in
          > microsoft.publi c.inetserver.as p.general:[color=green]
          >> for each SesVar in Session.Content s
          >> if( Session.Content s(SesVar) <> "" ) then[/color]
          >
          > [you can do without the () in vbs][/color]

          I know, but I find it more readable.

          [color=blue]
          > The variable value is in SesVar itself, so:
          >
          > for each SesVar in Session.Content s
          > if SesVar <> "" then response.write SesVar & "<br>"
          > next[/color]

          Not true I am afraid. SesVar contains the name, not the value. And I like to
          have both. But the posting from Aaron gave me the solution I think.


          Comment

          • Cecil Westerhof

            #6
            Re: Problem with Session.Content s

            "Aaron [SQL Server MVP]" <ten.xoc@dnartr eb.noraa> wrote in message
            news:%23%234%23 0LY0EHA.1260@TK 2MSFTNGP12.phx. gbl...[color=blue]
            > What does "crashes" mean? If it is type mismatch, then you might want to
            > make sure you exclude any arrays or other complex data types/objects from
            > your comparison. Please see http://www.aspfaq.com/2524[/color]

            If I remember well it was something like that yes. It could happen with one
            session, but at the same moment another session would not have a problem. It
            did not happen often, but it was very anoying when it did. I'll implement
            the code.


            Comment

            • Cecil Westerhof

              #7
              Re: Problem with Session.Content s

              "Cecil Westerhof" <someone@micros oft.com> wrote in message
              news:eYe9MQh0EH A.1392@TK2MSFTN GP14.phx.gbl...[color=blue]
              > "Aaron [SQL Server MVP]" <ten.xoc@dnartr eb.noraa> wrote in message
              > news:%23%234%23 0LY0EHA.1260@TK 2MSFTNGP12.phx. gbl...[color=green]
              >> What does "crashes" mean? If it is type mismatch, then you might want to
              >> make sure you exclude any arrays or other complex data types/objects from
              >> your comparison. Please see http://www.aspfaq.com/2524[/color]
              >
              > If I remember well it was something like that yes. It could happen with
              > one session, but at the same moment another session would not have a
              > problem. It did not happen often, but it was very anoying when it did.
              > I'll implement the code.[/color]

              That solved the problem. For one reason or another the programmer that wrote
              the application used session to store two objects that where only used in
              the current program. So I would think that you do not need a session
              variable for this. One was set to nothing (but to late) and the other was
              ignored. So I inserted everywhere where the programs could be exited a
              Session.Content s.Remove.


              Comment

              Working...