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

T

thomson

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
 
T

thomson

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 said:
Do you get any error?

Eliyahu

thomson said:
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
 
H

Hans Kesting

thomson said:
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
 
P

Patrice

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
 
P

Patrice

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 said:
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 said:
Do you get any error?

Eliyahu

thomson said:
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
 
T

thomson

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
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 said:
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
 
T

thomson

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
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
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 said:
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
 
P

Patrice

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" <[email protected]> a écrit dans le message de
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
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
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 said:
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
 
K

Kevin Spencer

This could be because Session("module") is null.

--
HTH,

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

thomson said:
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 said:
Do you get any error?

Eliyahu

thomson said:
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
 
E

Eliyahu Goldin

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 said:
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 said:
Do you get any error?

Eliyahu

thomson said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top