473,799 Members | 3,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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["userdetail s"] = 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(Obj ect sender, EventArgs e)
{

FormsAuthentica tion.SignOut();

}

HELP...

Nov 18 '05 #1
2 1292


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.InvalidC astException: 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["JobseekerI nfo"];

Line 34: DataRow row = myJobseeker.Tab les[JobseekerData.T ABLE_JOBSEEEKER].Rows[0];

Line 35: Session["UserFirstN ame"] = row[JobseekerData.F LD_FIRST_NAME].ToString();

Source File: C:\Inetpub\wwwr oot\JR\JobSeeke r\JobSeekerHome .aspx.cs Line: 33

Stack Trace:



[InvalidCastExce ption: Specified cast is not valid.]

JR.Web.JobSeeke r.JobSeekerHome .Page_Load(Obje ct sender, EventArgs e) in C:\Inetpub\wwwr oot\JR\JobSeeke r\JobSeekerHome .aspx.cs:33

System.Web.UI.C ontrol.OnLoad(E ventArgs e)

System.Web.UI.C ontrol.LoadRecu rsive()

System.Web.UI.P age.ProcessRequ estMain()



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

Version Information: Microsoft .NET Framework Version:1.1.432 2.573; ASP.NET Version:1.1.432 2.903
"Darren Clark" <dc******@hotma il.com> wrote in message news:eH******** ******@TK2MSFTN GP11.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["userdetail s"] = 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(Obj ect sender, EventArgs e)
{

FormsAuthentica tion.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["userdetail s"] = 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(Obj ect sender, EventArgs e)
{

FormsAuthentica tion.SignOut();

}

HELP...

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7226
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 some properties objUserInfo.UserName = txtUserName.text.trim objUserInfo...
1
2029
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 problem but I'm hoping the experts can help me figure that out. Our application uses a session variable to "pass" info from one form to the next. It has always worked fine for our users until a few weeks ago when one of our users started having a...
6
656
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, but I can't get the value is stored in it. How can I do that? Thanks a lot!
7
4202
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 code for 6 hours and stops. I've found the problem to be the Set MySession = CreateObject("MAPI.Session")
5
2615
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 response with a suitable resolution. So here goes ... We have a web site which stores an instance of a class into a Session, which is used in a number of pages. The code looks something like:
9
2456
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 at http://www.lamartin.com/dotnet/sessiontestset.aspx, were I set Session, Application and Cache variables on the first page and then on the second page view them as the second page is refreshed every five seconds. Before 10 refreshes, the...
1
737
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 find one? Thanks Werner P.S. Somehow I did not manage to do a followup in Googles newsgroups.
1
2415
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 the differences, e.g that every object you store in SQLSession state have to be serializable, but other differences are very unfortunate.
5
2092
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 store, there is only one complicated object in this Session, but to get it on SessionStart to make a copy this is a problem. Maybe using Application or whatever? Or this data is divided and inaccessible anyway? Just D.
7
2047
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, it retreives the Menu from session and assigns its reference to Menu1. Within the Page_Load event I can see its internal values which have been retreived for each menu item and so it looks good. However, when the Render method is called of...
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10491
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10247
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.