467,894 Members | 1,540 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,894 developers. It's quick & easy.

Session problem....

I am having some troubles with Sessin varables dieing..

Basically ihave my own class structure called USER that once the user logs in i save it to a session var called
Session["userdetails"] = myUserObject;

All this works fine until sometimes it is like my sessoin vars just die and then trying to do a cast on them will result in a invalid cast error EVEN though the object is the same type..

I am not sure if the problem is that i am using forms authentication and that it times out AFTER session vars timeout...
eg the session is diing yet the forms authentication is still alive... as i can still view the page.. but my session vars arent there anymore.
Whereas if the forms authentication was dead it should refuse access to the page.

Has anyone had any problems like this at all? Can you give me anything to look at?

I am sort of at a loss... as i would think that if the sessoin ends it would call the session_end
and i make sure i signout the forms authentication.

protected void Session_End(Object sender, EventArgs e)
{

FormsAuthentication.SignOut();

}

HELP...

Nov 18 '05 #1
  • viewed: 1059
Share:
2 Replies


Actually... here is the error message that i keep getting.,.
Now the thing is... if the object is there.. the cast works FINE...

BUT

what i dont understand is why the session var is not there? it never gets set to null in code.

So asp.net is doing it somewhere... by why?

and even if it is .. why is session_end being called to Log the user out of the forms authentication THEREFORE redirecting the user to the login page?
--------------------------------------------------------------------------------

Specified cast is not valid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:



Line 31: // Put user code to initialize the page here

Line 32: JobseekerData myJobseeker = new JobseekerData();

Line 33: myJobseeker = (JobseekerData)Session["JobseekerInfo"];

Line 34: DataRow row = myJobseeker.Tables[JobseekerData.TABLE_JOBSEEEKER].Rows[0];

Line 35: Session["UserFirstName"] = row[JobseekerData.FLD_FIRST_NAME].ToString();

Source File: C:\Inetpub\wwwroot\JR\JobSeeker\JobSeekerHome.aspx .cs Line: 33

Stack Trace:



[InvalidCastException: Specified cast is not valid.]

JR.Web.JobSeeker.JobSeekerHome.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\JR\JobSeeker\JobSeekerHome.aspx .cs:33

System.Web.UI.Control.OnLoad(EventArgs e)

System.Web.UI.Control.LoadRecursive()

System.Web.UI.Page.ProcessRequestMain()



--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.903
"Darren Clark" <dc******@hotmail.com> wrote in message news:eH**************@TK2MSFTNGP11.phx.gbl...
I am having some troubles with Sessin varables dieing..

Basically ihave my own class structure called USER that once the user logs in i save it to a session var called
Session["userdetails"] = myUserObject;

All this works fine until sometimes it is like my sessoin vars just die and then trying to do a cast on them will result in a invalid cast error EVEN though the object is the same type..

I am not sure if the problem is that i am using forms authentication and that it times out AFTER session vars timeout...
eg the session is diing yet the forms authentication is still alive... as i can still view the page.. but my session vars arent there anymore.
Whereas if the forms authentication was dead it should refuse access to the page.

Has anyone had any problems like this at all? Can you give me anything to look at?

I am sort of at a loss... as i would think that if the sessoin ends it would call the session_end
and i make sure i signout the forms authentication.

protected void Session_End(Object sender, EventArgs e)
{

FormsAuthentication.SignOut();

}

HELP...

Nov 18 '05 #2
Darren,

Try using the state server instead of in process state management. There are too many things that can cause the ASPNET process to restart which kills the sessions when running in process.
-Calvin Luttrell
ProjectThunder.com

I am having some troubles with Sessin varables dieing..

Basically ihave my own class structure called USER that once the user logs in i save it to a session var called
Session["userdetails"] = myUserObject;

All this works fine until sometimes it is like my sessoin vars just die and then trying to do a cast on them will result in a invalid cast error EVEN though the object is the same type..

I am not sure if the problem is that i am using forms authentication and that it times out AFTER session vars timeout...
eg the session is diing yet the forms authentication is still alive... as i can still view the page.. but my session vars arent there anymore.
Whereas if the forms authentication was dead it should refuse access to the page.

Has anyone had any problems like this at all? Can you give me anything to look at?

I am sort of at a loss... as i would think that if the sessoin ends it would call the session_end
and i make sure i signout the forms authentication.

protected void Session_End(Object sender, EventArgs e)
{

FormsAuthentication.SignOut();

}

HELP...

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Billy Jacobs | last post: by
1 post views Thread by Scott Wickham | last post: by
6 posts views Thread by Lina Manjarres | last post: by
5 posts views Thread by Mark Rodrigues | last post: by
9 posts views Thread by William LaMartin | last post: by
1 post views Thread by Werner | last post: by
5 posts views Thread by Just D. | last post: by
7 posts views Thread by Mr Newbie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.