sessions in ASP.NET vs ASP

  • Thread starter Thread starter Bruno Alexandre
  • Start date Start date
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)
 
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
 
Don't forget to cast it

an example would be

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

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


Cheer

J
 
(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 )
 
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 )
 
Back
Top