Friday, March 16, 2012

Persistent Forms Authentication - and Session Variables

Hi All!

I'm doing an ASP.NET project which uses Persistent Forms Authentication
(i.e. once user logged in, they don't have to log in again). However Session
variables are erased after Session has timed out. So I need to re-populate
user specific session variables (such as user email, DOB, Full Name...etc)
when Session has ended.

But strangely, when I tried to do something like...

Dim strArrayUserInfo(10) as String

strArrayUserInfo(0) = drDataReader("FName").ToString
strArrayUserInfo(1) = drDataReader("LName").ToString
strArrayUserInfo(2) = drDataReader("Email").ToString

Session("UserInfoArray") = strArrayUserInfo

I get System.StackOverflowException. If I comment out that line, application
runs correctly but fail at the point where Session("UserInfoArray") is
accessed (i.e. Null Exception). So I de-comment the above code and I was
thrown System.StackOverflowException again.

What could be the problem? I was merely assigning a variable to Session
variable collection. Why ASP.NET throws System.StackOverflowException??

Thank you all in advance!!!!

Max"Max" <zero@.maxdot.com.com> wrote in message
news:ukaISv57EHA.2016@.TK2MSFTNGP15.phx.gbl...
> Hi All!
> I'm doing an ASP.NET project which uses Persistent Forms Authentication
> (i.e. once user logged in, they don't have to log in again). However
> Session variables are erased after Session has timed out. So I need to
> re-populate user specific session variables (such as user email, DOB, Full
> Name...etc) when Session has ended.
> But strangely, when I tried to do something like...
> Dim strArrayUserInfo(10) as String
> strArrayUserInfo(0) = drDataReader("FName").ToString
> strArrayUserInfo(1) = drDataReader("LName").ToString
> strArrayUserInfo(2) = drDataReader("Email").ToString
> Session("UserInfoArray") = strArrayUserInfo
> I get System.StackOverflowException. If I comment out that line,
> application runs correctly but fail at the point where
> Session("UserInfoArray") is accessed (i.e. Null Exception). So I
> de-comment the above code and I was thrown System.StackOverflowException
> again.
> What could be the problem? I was merely assigning a variable to Session
> variable collection. Why ASP.NET throws System.StackOverflowException??

I bet you have something else called "Session". Change the line to refer to
HttpContext.Current.Session and see if that's any better.

John Saunders
Hi John,

Thanks for the quick response! Unfortunately, I get the same error :(

Any ideas?

Max

"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:ew5r0757EHA.2016@.TK2MSFTNGP15.phx.gbl...
> "Max" <zero@.maxdot.com.com> wrote in message
> news:ukaISv57EHA.2016@.TK2MSFTNGP15.phx.gbl...
>> Hi All!
>>
>> I'm doing an ASP.NET project which uses Persistent Forms Authentication
>> (i.e. once user logged in, they don't have to log in again). However
>> Session variables are erased after Session has timed out. So I need to
>> re-populate user specific session variables (such as user email, DOB,
>> Full Name...etc) when Session has ended.
>>
>> But strangely, when I tried to do something like...
>>
>> Dim strArrayUserInfo(10) as String
>>
>> strArrayUserInfo(0) = drDataReader("FName").ToString
>> strArrayUserInfo(1) = drDataReader("LName").ToString
>> strArrayUserInfo(2) = drDataReader("Email").ToString
>>
>> Session("UserInfoArray") = strArrayUserInfo
>>
>> I get System.StackOverflowException. If I comment out that line,
>> application runs correctly but fail at the point where
>> Session("UserInfoArray") is accessed (i.e. Null Exception). So I
>> de-comment the above code and I was thrown System.StackOverflowException
>> again.
>>
>> What could be the problem? I was merely assigning a variable to Session
>> variable collection. Why ASP.NET throws System.StackOverflowException??
> I bet you have something else called "Session". Change the line to refer
> to HttpContext.Current.Session and see if that's any better.
> John Saunders
"Max" <zero@.maxdot.com.com> wrote in message
news:edEOMA67EHA.2552@.TK2MSFTNGP09.phx.gbl...
> Hi John,
> Thanks for the quick response! Unfortunately, I get the same error :(

Several ideas, none brilliant.

1) Simplify, simplify, simplify
1a) Instead of filling from the datareader, try setting the array elements
to constants. It's simpler.
1b) Try using Session("a"). It's simpler.
2) Are you setting all 10 elements of the array?
3) Turn Options Strict On.

John Saunders

> "John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
> news:ew5r0757EHA.2016@.TK2MSFTNGP15.phx.gbl...
>> "Max" <zero@.maxdot.com.com> wrote in message
>> news:ukaISv57EHA.2016@.TK2MSFTNGP15.phx.gbl...
>>> Hi All!
>>>
>>> I'm doing an ASP.NET project which uses Persistent Forms Authentication
>>> (i.e. once user logged in, they don't have to log in again). However
>>> Session variables are erased after Session has timed out. So I need to
>>> re-populate user specific session variables (such as user email, DOB,
>>> Full Name...etc) when Session has ended.
>>>
>>> But strangely, when I tried to do something like...
>>>
>>> Dim strArrayUserInfo(10) as String
>>>
>>> strArrayUserInfo(0) = drDataReader("FName").ToString
>>> strArrayUserInfo(1) = drDataReader("LName").ToString
>>> strArrayUserInfo(2) = drDataReader("Email").ToString
>>>
>>> Session("UserInfoArray") = strArrayUserInfo
>>>
>>> I get System.StackOverflowException. If I comment out that line,
>>> application runs correctly but fail at the point where
>>> Session("UserInfoArray") is accessed (i.e. Null Exception). So I
>>> de-comment the above code and I was thrown System.StackOverflowException
>>> again.
>>>
>>> What could be the problem? I was merely assigning a variable to
>>> Session variable collection. Why ASP.NET throws
>>> System.StackOverflowException??
>>
>> I bet you have something else called "Session". Change the line to refer
>> to HttpContext.Current.Session and see if that's any better.
>>
>> John Saunders
>>
>>
Hi John,

I tried reducing the Array length to 3 and still it didn't work. This is a
mystery and a nightmare.

Max

"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:uFWbK777EHA.2568@.TK2MSFTNGP10.phx.gbl...
> "Max" <zero@.maxdot.com.com> wrote in message
> news:edEOMA67EHA.2552@.TK2MSFTNGP09.phx.gbl...
>> Hi John,
>>
>> Thanks for the quick response! Unfortunately, I get the same error :(
> Several ideas, none brilliant.
> 1) Simplify, simplify, simplify
> 1a) Instead of filling from the datareader, try setting the array elements
> to constants. It's simpler.
> 1b) Try using Session("a"). It's simpler.
> 2) Are you setting all 10 elements of the array?
> 3) Turn Options Strict On.
> John Saunders
>
>> "John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
>> news:ew5r0757EHA.2016@.TK2MSFTNGP15.phx.gbl...
>>> "Max" <zero@.maxdot.com.com> wrote in message
>>> news:ukaISv57EHA.2016@.TK2MSFTNGP15.phx.gbl...
>>>> Hi All!
>>>>
>>>> I'm doing an ASP.NET project which uses Persistent Forms Authentication
>>>> (i.e. once user logged in, they don't have to log in again). However
>>>> Session variables are erased after Session has timed out. So I need to
>>>> re-populate user specific session variables (such as user email, DOB,
>>>> Full Name...etc) when Session has ended.
>>>>
>>>> But strangely, when I tried to do something like...
>>>>
>>>> Dim strArrayUserInfo(10) as String
>>>>
>>>> strArrayUserInfo(0) = drDataReader("FName").ToString
>>>> strArrayUserInfo(1) = drDataReader("LName").ToString
>>>> strArrayUserInfo(2) = drDataReader("Email").ToString
>>>>
>>>> Session("UserInfoArray") = strArrayUserInfo
>>>>
>>>> I get System.StackOverflowException. If I comment out that line,
>>>> application runs correctly but fail at the point where
>>>> Session("UserInfoArray") is accessed (i.e. Null Exception). So I
>>>> de-comment the above code and I was thrown
>>>> System.StackOverflowException again.
>>>>
>>>> What could be the problem? I was merely assigning a variable to
>>>> Session variable collection. Why ASP.NET throws
>>>> System.StackOverflowException??
>>>
>>> I bet you have something else called "Session". Change the line to refer
>>> to HttpContext.Current.Session and see if that's any better.
>>>
>>> John Saunders
>>>
>>>
>>
>>
"Max" <zero@.maxdot.com.com> wrote in message
news:erNBq2U8EHA.2124@.TK2MSFTNGP14.phx.gbl...
> Hi John,
> I tried reducing the Array length to 3 and still it didn't work. This is a
> mystery and a nightmare.

Did you try using an array filled with constants? Did you try using
Session("a")? Have you turned Options Strict On?

John Saunders

> "John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
> news:uFWbK777EHA.2568@.TK2MSFTNGP10.phx.gbl...
>> "Max" <zero@.maxdot.com.com> wrote in message
>> news:edEOMA67EHA.2552@.TK2MSFTNGP09.phx.gbl...
>>> Hi John,
>>>
>>> Thanks for the quick response! Unfortunately, I get the same error :(
>>
>> Several ideas, none brilliant.
>>
>> 1) Simplify, simplify, simplify
>> 1a) Instead of filling from the datareader, try setting the array
>> elements to constants. It's simpler.
>> 1b) Try using Session("a"). It's simpler.
>> 2) Are you setting all 10 elements of the array?
>> 3) Turn Options Strict On.
>>
>> John Saunders
>>
>>
>>
>>> "John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
>>> news:ew5r0757EHA.2016@.TK2MSFTNGP15.phx.gbl...
>>>> "Max" <zero@.maxdot.com.com> wrote in message
>>>> news:ukaISv57EHA.2016@.TK2MSFTNGP15.phx.gbl...
>>>>> Hi All!
>>>>>
>>>>> I'm doing an ASP.NET project which uses Persistent Forms
>>>>> Authentication (i.e. once user logged in, they don't have to log in
>>>>> again). However Session variables are erased after Session has timed
>>>>> out. So I need to re-populate user specific session variables (such as
>>>>> user email, DOB, Full Name...etc) when Session has ended.
>>>>>
>>>>> But strangely, when I tried to do something like...
>>>>>
>>>>> Dim strArrayUserInfo(10) as String
>>>>>
>>>>> strArrayUserInfo(0) = drDataReader("FName").ToString
>>>>> strArrayUserInfo(1) = drDataReader("LName").ToString
>>>>> strArrayUserInfo(2) = drDataReader("Email").ToString
>>>>>
>>>>> Session("UserInfoArray") = strArrayUserInfo
>>>>>
>>>>> I get System.StackOverflowException. If I comment out that line,
>>>>> application runs correctly but fail at the point where
>>>>> Session("UserInfoArray") is accessed (i.e. Null Exception). So I
>>>>> de-comment the above code and I was thrown
>>>>> System.StackOverflowException again.
>>>>>
>>>>> What could be the problem? I was merely assigning a variable to
>>>>> Session variable collection. Why ASP.NET throws
>>>>> System.StackOverflowException??
>>>>
>>>> I bet you have something else called "Session". Change the line to
>>>> refer to HttpContext.Current.Session and see if that's any better.
>>>>
>>>> John Saunders
>>>>
>>>>
>>>
>>>
>>
>>

0 comments:

Post a Comment