Wednesday, March 21, 2012

Passing A Session Variable Form Page to Page ~ No Working

Hi All,

I am trying to passing a session variable from Page to Page but its not working!

the user basicaly logins in on the login.aspx and when their credentials are verifed by the MSSAccess database they are tehn redirected to the next page...heres a snip of code

~~~~~~~~~~~~~~
session("ID") = dslogin.tables("UserInfo").rows(0).item("ID")

response.redirect("./success.aspx")
~~~~~~~~~~~~~~~~~~

Heres the code for the page I am trying to access after beigng verifed

~~~~~~~~~~
sub page_load(byval sender as object, byval e as eventargs)

if Len(Session("ID")) = 0 then

response.redirect("./login.aspx")

end if
~~~~~~~~~~~~~~~

wots happeniong is even if you use the correct userid and password the code on the second page still sends you back to the login.aspx???

Can anyone please shine a light on this as I am going around in circles...

many thanks

Tony

end subHi Tony,
Any chance you are redirecting from https to http?
Hi & Thanks for your response

its all HTTP:
are you debugging to verify that your DataBase value is actually being inserted into Session upon logging in?
no ...but i would love to learn how......

Please can you tell me how to do this plase

I have this name sapce in

<%@. Page Language="VB" Debug="true" %
rgs

Tony
Hi,

Thanks for your help so far..

I think it is passing but now I am gettimng this error and I dont know what it means!!

Compiler Error Message: BC30545: Property access must assign to the property or use its value.

Source Error:

Line 7: sub page_load(byval sender as object, byval e as eventargs)
Line 8:
Line 9: request.querystring("UserID")
Line 10:
Line 11: if Len(Session("UserID")) = 0 then

any help would be most appreciated

rgs

Tony
You have to assign a variable to store the QueryString data, like:

dim foo as string = request.querystring("bar")

Are you using VS.NET and developing this app locally? If so you can just add a breakpoint to a line of code by pressing f9 and when that line is met, you can step through the code and hover you mouse over variables to see what they contain, or add them to the watch list.

0 comments:

Post a Comment