By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,732 Members | 842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,732 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Nov 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Do you get any error?

Eliyahu

"thomson" <sa**********@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
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

Nov 19 '05 #2

P: n/a

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" <sa**********@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
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


Nov 19 '05 #3

P: n/a
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
Nov 19 '05 #4

P: n/a
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" <sa**********@yahoo.com> a écrit dans le message de
news:11*********************@g44g2000cwa.googlegro ups.com...
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

Nov 19 '05 #5

P: n/a
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" <sa**********@yahoo.com> a écrit dans le message de
news:11**********************@g47g2000cwa.googlegr oups.com...

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" <sa**********@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
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

Nov 19 '05 #6

P: n/a
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" <sa**********@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...

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" <sa**********@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
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

Nov 19 '05 #7

P: n/a

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" <sa**********@yahoo.com> a écrit dans le message de
news:11*********************@g44g2000cwa.googlegro ups.com...
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


Nov 19 '05 #8

P: n/a
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" <sa**********@yahoo.com> a écrit dans le message de
news:11*********************@g44g2000cwa.googlegro ups.com...
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


Nov 19 '05 #9

P: n/a
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" <sa**********@yahoo.com> a écrit dans le message de
news:11*********************@g44g2000cwa.googlegro ups.com...
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" <sa**********@yahoo.com> a écrit dans le message de
news:11*********************@g44g2000cwa.googlegro ups.com...
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

Nov 19 '05 #10

P: n/a
This could be because Session("module") is null.

--
HTH,

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

"thomson" <sa**********@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...

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" <sa**********@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
> 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
>

Nov 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.