Difference between Session["var"] and Session("var")

Discussion in 'ASP .Net' started by thomson, Jun 20, 2005.

  1. thomson

    thomson Guest

    Hi,
    i create a session variable in C# as follows Session["var"] ,
    but iam not able to access the variable in VB.net

    like intmode=Session("var");

    Why is that ?

    Regards

    thomson
     
    thomson, Jun 20, 2005
    #1
    1. Advertising

  2. thomson

    thomson Guest

    iam not getting an error but while i retrieve the value somtething like
    this

    if session("module")="" then
    intmodle=50
    else
    intmodle=session("module")
    end if

    when i come to the first "if " it skips and no statement is executed

    One morething can i add querystring variable to a Server.transfer
    method
    regards

    thomson
    Eliyahu Goldin wrote:
    > Do you get any error?
    >
    > Eliyahu
    >
    > "thomson" <> wrote in message
    > news:...
    > > Hi,
    > > i create a session variable in C# as follows Session["var"] ,
    > > but iam not able to access the variable in VB.net
    > >
    > > like intmode=Session("var");
    > >
    > > Why is that ?
    > >
    > > Regards
    > >
    > > thomson
    > >
     
    thomson, Jun 20, 2005
    #2
    1. Advertising

  3. thomson

    Hans Kesting Guest

    thomson wrote:
    > Hi,
    > i create a session variable in C# as follows Session["var"] ,
    > but iam not able to access the variable in VB.net
    >
    > like intmode=Session("var");
    >
    > Why is that ?
    >
    > Regards
    >
    > thomson


    It's just syntax:
    in C# you use [ ]
    in VB you use ( )

    apart from that, it's identical.

    Hans Kesting
     
    Hans Kesting, Jun 20, 2005
    #3
  4. thomson

    Patrice Guest

    Do you have a particular message or does it come "empty" ?

    If the later, it's likely you have two sessions (check SessionID). This is
    likely not a problem with the programming language but rather with how you
    lannch these two pages (you could use the same language in both to see if
    it's still shows the same problem).

    Patrice

    --

    "thomson" <> a écrit dans le message de
    news:...
    > Hi,
    > i create a session variable in C# as follows Session["var"] ,
    > but iam not able to access the variable in VB.net
    >
    > like intmode=Session("var");
    >
    > Why is that ?
    >
    > Regards
    >
    > thomson
    >
     
    Patrice, Jun 20, 2005
    #4
  5. thomson

    Patrice Guest

    Use Response.write to see which branch is executed. Also dump the content
    and use Response.Write(Session("module")="") to see what happens.

    For now all the code you show reads the variable. How do you create it ?

    I ask this because you said previously you *create* a session variable as
    follows :
    intmode=Session("var");

    It doesn't create a session variable, it reads it.

    Patrice

    --

    "thomson" <> a écrit dans le message de
    news:...
    >
    > iam not getting an error but while i retrieve the value somtething like
    > this
    >
    > if session("module")="" then
    > intmodle=50
    > else
    > intmodle=session("module")
    > end if
    >
    > when i come to the first "if " it skips and no statement is executed
    >
    > One morething can i add querystring variable to a Server.transfer
    > method
    > regards
    >
    > thomson
    > Eliyahu Goldin wrote:
    > > Do you get any error?
    > >
    > > Eliyahu
    > >
    > > "thomson" <> wrote in message
    > > news:...
    > > > Hi,
    > > > i create a session variable in C# as follows Session["var"] ,
    > > > but iam not able to access the variable in VB.net
    > > >
    > > > like intmode=Session("var");
    > > >
    > > > Why is that ?
    > > >
    > > > Regards
    > > >
    > > > thomson
    > > >

    >
     
    Patrice, Jun 20, 2005
    #5
  6. thomson

    thomson Guest

    Hi,
    Actually the issue is that i do have a page with several buttons ,
    when i click a button i call a javascript to open a new window with a
    query string value.

    The new window has 3 frames before itself i retrieve the query string
    value into a session like Session["module"].

    But one of the left frame is written in VB.net where it access the
    Session Variable.

    In order to avoid a new open window , and i used Server.transfer to the
    frame page, But nothing is coming



    Regards

    thomson

    Patrice wrote:
    > Do you have a particular message or does it come "empty" ?
    >
    > If the later, it's likely you have two sessions (check SessionID). This is
    > likely not a problem with the programming language but rather with how you
    > lannch these two pages (you could use the same language in both to see if
    > it's still shows the same problem).
    >
    > Patrice
    >
    > --
    >
    > "thomson" <> a écrit dans le message de
    > news:...
    > > Hi,
    > > i create a session variable in C# as follows Session["var"] ,
    > > but iam not able to access the variable in VB.net
    > >
    > > like intmode=Session("var");
    > >
    > > Why is that ?
    > >
    > > Regards
    > >
    > > thomson
    > >
     
    thomson, Jun 20, 2005
    #6
  7. Do you get any error?

    Eliyahu

    "thomson" <> wrote in message
    news:...
    > Hi,
    > i create a session variable in C# as follows Session["var"] ,
    > but iam not able to access the variable in VB.net
    >
    > like intmode=Session("var");
    >
    > Why is that ?
    >
    > Regards
    >
    > thomson
    >
     
    Eliyahu Goldin, Jun 20, 2005
    #7
  8. thomson

    thomson Guest

    Hi all

    this is what i did

    try
    {
    Server.Transfer("MainForm.aspx?module=50");
    }
    catch(Exception objEx)
    {
    Response.Write(objEx.Message);
    }

    In the MainForm.aspx

    i do have a code <%Session["module"]=Request.QueryString["module"];%>

    and an exception is raised in the code

    What could be the reason

    Regards

    thomson

    thomson wrote:
    > Hi,
    > Actually the issue is that i do have a page with several buttons ,
    > when i click a button i call a javascript to open a new window with a
    > query string value.
    >
    > The new window has 3 frames before itself i retrieve the query string
    > value into a session like Session["module"].
    >
    > But one of the left frame is written in VB.net where it access the
    > Session Variable.
    >
    > In order to avoid a new open window , and i used Server.transfer to the
    > frame page, But nothing is coming
    >
    >
    >
    > Regards
    >
    > thomson
    >
    > Patrice wrote:
    > > Do you have a particular message or does it come "empty" ?
    > >
    > > If the later, it's likely you have two sessions (check SessionID). Thisis
    > > likely not a problem with the programming language but rather with how you
    > > lannch these two pages (you could use the same language in both to see if
    > > it's still shows the same problem).
    > >
    > > Patrice
    > >
    > > --
    > >
    > > "thomson" <> a écrit dans le message de
    > > news:...
    > > > Hi,
    > > > i create a session variable in C# as follows Session["var"] ,
    > > > but iam not able to access the variable in VB.net
    > > >
    > > > like intmode=Session("var");
    > > >
    > > > Why is that ?
    > > >
    > > > Regards
    > > >
    > > > thomson
    > > >
     
    thomson, Jun 20, 2005
    #8
  9. thomson

    Patrice Guest

    Please avoid mixing distinct questions in the same thread...

    1) For session have you checked SessionID to see if you actually have two
    distincts sessions
    2) Server.Transfer is server side. You don't transmit parameters this way.
    Either use Response.Redirect or see :
    http://www.dotnetbips.com/displayarticle.aspx?id=79
    (parameters are exposed through properties from the source page and read
    from the destination page through Context.Handler to get access to the
    source page).

    Patrice


    --

    "thomson" <> a écrit dans le message de
    news:...
    Hi all

    this is what i did

    try
    {
    Server.Transfer("MainForm.aspx?module=50");
    }
    catch(Exception objEx)
    {
    Response.Write(objEx.Message);
    }

    In the MainForm.aspx

    i do have a code <%Session["module"]=Request.QueryString["module"];%>

    and an exception is raised in the code

    What could be the reason

    Regards

    thomson

    thomson wrote:
    > Hi,
    > Actually the issue is that i do have a page with several buttons ,
    > when i click a button i call a javascript to open a new window with a
    > query string value.
    >
    > The new window has 3 frames before itself i retrieve the query string
    > value into a session like Session["module"].
    >
    > But one of the left frame is written in VB.net where it access the
    > Session Variable.
    >
    > In order to avoid a new open window , and i used Server.transfer to the
    > frame page, But nothing is coming
    >
    >
    >
    > Regards
    >
    > thomson
    >
    > Patrice wrote:
    > > Do you have a particular message or does it come "empty" ?
    > >
    > > If the later, it's likely you have two sessions (check SessionID). This

    is
    > > likely not a problem with the programming language but rather with how

    you
    > > lannch these two pages (you could use the same language in both to see

    if
    > > it's still shows the same problem).
    > >
    > > Patrice
    > >
    > > --
    > >
    > > "thomson" <> a écrit dans le message de
    > > news:...
    > > > Hi,
    > > > i create a session variable in C# as follows Session["var"] ,
    > > > but iam not able to access the variable in VB.net
    > > >
    > > > like intmode=Session("var");
    > > >
    > > > Why is that ?
    > > >
    > > > Regards
    > > >
    > > > thomson
    > > >
     
    Patrice, Jun 20, 2005
    #9
  10. This could be because Session("module") is null.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Ambiguity has a certain quality to it.

    "thomson" <> wrote in message
    news:...
    >
    > iam not getting an error but while i retrieve the value somtething like
    > this
    >
    > if session("module")="" then
    > intmodle=50
    > else
    > intmodle=session("module")
    > end if
    >
    > when i come to the first "if " it skips and no statement is executed
    >
    > One morething can i add querystring variable to a Server.transfer
    > method
    > regards
    >
    > thomson
    > Eliyahu Goldin wrote:
    >> Do you get any error?
    >>
    >> Eliyahu
    >>
    >> "thomson" <> wrote in message
    >> news:...
    >> > Hi,
    >> > i create a session variable in C# as follows Session["var"] ,
    >> > but iam not able to access the variable in VB.net
    >> >
    >> > like intmode=Session("var");
    >> >
    >> > Why is that ?
    >> >
    >> > Regards
    >> >
    >> > thomson
    >> >

    >
     
    Kevin Spencer, Jun 20, 2005
    #10
  11. There can be only 3 options.
    1. intmodle=50 is executed
    2. intmodle=session("module") is executed
    3. an exception is raised.

    What do you observe?

    Eliyahu

    "thomson" <> wrote in message
    news:...
    >
    > iam not getting an error but while i retrieve the value somtething like
    > this
    >
    > if session("module")="" then
    > intmodle=50
    > else
    > intmodle=session("module")
    > end if
    >
    > when i come to the first "if " it skips and no statement is executed
    >
    > One morething can i add querystring variable to a Server.transfer
    > method
    > regards
    >
    > thomson
    > Eliyahu Goldin wrote:
    > > Do you get any error?
    > >
    > > Eliyahu
    > >
    > > "thomson" <> wrote in message
    > > news:...
    > > > Hi,
    > > > i create a session variable in C# as follows Session["var"] ,
    > > > but iam not able to access the variable in VB.net
    > > >
    > > > like intmode=Session("var");
    > > >
    > > > Why is that ?
    > > >
    > > > Regards
    > > >
    > > > thomson
    > > >

    >
     
    Eliyahu Goldin, Jun 20, 2005
    #11
    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. thomson
    Replies:
    0
    Views:
    387
    thomson
    Jun 20, 2005
  2. daniele.g
    Replies:
    4
    Views:
    481
    Joe Pfeiffer
    Jul 15, 2011
  3. Shea Martin

    difference between @var and self.var

    Shea Martin, Jun 21, 2006, in forum: Ruby
    Replies:
    2
    Views:
    153
    Shea Martin
    Jun 22, 2006
  4. Replies:
    17
    Views:
    193
  5. erdibalint
    Replies:
    7
    Views:
    106
    Evertjan.
    Feb 21, 2008
Loading...

Share This Page