sessions in ASP.NET vs ASP

B

Bruno Alexandre

could you help me in this issue, please?


in ASP I write/read sessions like


<% session("StartDateTime") = now() %>


<%=(session("StartDateTime"))%>



why I can't it use in ASP.NET ? I can't find any tutorial about it,
just the use of cookies, witch is a little different...

can you help me how to use the ASP session in ASP.NET pages? or how to
write/read session in ASP.NET page?


thank you in advance.


Bruno Alexandre
(Sintra, PORTUGAL)
 
A

Antoni Biliardis

For the most part, it is the same as in classic ASP. Just prefix it with
"Context".

Classic ASP: session("StartDateTime")
ASP.NET: Context.Session("StartDateTime")

Hope this helps,
Antoni
_____________________________________________________________
B&D Technologies
http://www.bd-tech.com
Antoni Biliardis - antoni(at)bd-tech.com
 
J

James Zhuo

Don't forget to cast it

an example would be

VB.NET
CType(Session("StartDateTime"), YourDataType))

C#.NET
(YourDataType)Session["StartDateTime"]


Cheer

J
 
B

Bruno Alexandre

(workin' with VB.NET)

it doesn't work...
could anyone help me on this? :(


Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30188: Declaration expected.

Source Error:


Line 8: dim msg as string = "Sessões"
Line 9:
Line 10: msg = context.session("SnPor-DIST-id")
Line 11:
Line 12: Sub Page_Load( Sender as Object, e As EventArgs )


Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30188: Declaration expected.

Source Error:


Line 8: dim msg as string = "Sessões"
Line 9:
Line 10: msg = ctype( session("SnPor-DIST-id"), string )
Line 11:
Line 12: Sub Page_Load( Sender as Object, e As EventArgs )
 
B

Bruno Alexandre

it doesn't work...
could you help me on this? :(


Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30188: Declaration expected.

Source Error:


Line 8: dim msg as string = "Sessões"
Line 9:
Line 10: msg = context.session("SnPor-DIST-id")
Line 11:
Line 12: Sub Page_Load( Sender as Object, e As EventArgs )


Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30188: Declaration expected.

Source Error:


Line 8: dim msg as string = "Sessões"
Line 9:
Line 10: msg = ctype( session("SnPor-DIST-id"), string )
Line 11:
Line 12: Sub Page_Load( Sender as Object, e As EventArgs )
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top