ASP vs ASP.NET sessions (2nd post)

  • Thread starter Thread starter Bruno Alexandre
  • Start date Start date
B

Bruno Alexandre

I there,

I'm trying to use the same session varaibles in both .asp and .aspx
pages, but I can't. (i'm using VB.NET)

Error using cast...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
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 )


Source File: D:\trabalhos Filtrarte\website
FLT\ats\asp\pt_ats_listaAssistencias.aspx Line: 10
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -

Error using session as in ASP page
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
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 )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -

using like ASP response.write page
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
<%= ">" & session("SnPor-DIST-id") & "<" %>

in the html code, I just have ><
seams the session is empty... but if I open the ASP page in the same moment,
I can see it isn't empty.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -

could anyone help me on this, please?
thank you in advance


Bruno Alexandre,
(Sintra, PORTUGAL)
 
There are 2 issues here

1) You are getting a compile time error. Not a runtime error. That means
your code cannot compile.

The reason it cannot compile, is that script blocks can have either
functions or just script code <script runat="server"></script> blocks may
contain ONLY functions and class level declaration. <% %> blocks may have
script code that just runs. Line 10 would belong in a <% %> type block -
and because it is not, you are getting a compile time error.

2) This will not work anyway, since ASP and ASP.NET run in 2 different
processes and thus cannot share session state. You will have to pass it via
query string, store it in a db, etc. Basically find another way to pass data
back and forth.
 
Back
Top