473,387 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
2 1272


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Billy Jacobs | last post by:
I am having a problem with my session variable being set to Null for no apparent reason. I am declaring it like the following when the user logs in. dim objUserInfo as new clsUserInfo 'Set...
1
by: Scott Wickham | last post by:
I'm having a problem saving session information on one form and retrieving it on a subsequent form...for only one out of a number of users. Actually, I'm not absolutely certain it's a session...
6
by: Lina Manjarres | last post by:
Hello, I have a session variable in a login page. Then I go to a form page where I uses the ProfileID and the UserID. Then I go to a result page where I would like to use the UserID as a filter,...
7
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same...
5
by: Mark Rodrigues | last post by:
Hi Everyone, I have been fighting a problem for a while and I wonder if someone out there can help. This problem has been presented in a number of news postings previously but I am yet to see a...
9
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
1
by: Werner | last post by:
Hi Patrick! Can you give an example of how to use a frameset inside an aspx-file? When I create a new frameset in Visual Studio.Net it just gives me a htm-File. Or give me a link where I can...
1
by: Johan Nedin | last post by:
Hello! I have a problem with SQLSession state on my ASP.NET pages. SQLSession state behaves very different from InProcess session state, which I think is very bad. I can understand some of...
5
by: Just D. | last post by:
Do we have any access to the Session object from a different Session? The idea is to save Session of a current user and then if he logs in again then return the Session back. It's not a problem to...
7
by: Mr Newbie | last post by:
I have written a Custom Control Menu. Its fairly simple but it works well enough. In order to simplify things I decided to store the Menu1 custom control in Session. In the page load event below,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.