0

I have a complex ASP.NET(c#) website which uses many web services. Every web services takes a username and password which I store in a session variable on login.

My problem is, when the session expires, which is very unpredictable (can be anytime), my website throws an object reference error.

What's the best way to go about capturing the session timeout in one place before it tries to use the web service with the expired session?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Diane2
  • 160
  • 3
  • 16
  • 1
    Why not just make sure you keep the session alive? http://stackoverflow.com/questions/1431733/keeping-asp-net-session-open-alive?rq=1 – EkoostikMartin Jun 13 '13 at 14:57
  • thanks for your response. I've tried doing that with and iframe that adds a header to update the session. I didn't really know whta I was doing and so it didn't work. Can you direct me how to keep the session alive? – Diane2 Jun 13 '13 at 15:03
  • did you click on the link I provided? The top answer in that link provides a nice way to try to keep an asp.net session alive. – EkoostikMartin Jun 13 '13 at 15:05
  • You should also be checking for null when you are accessing the session. Session will eventually expire for some reason, so you should handle it gracefully. – matt-dot-net Jun 13 '13 at 15:22
  • EkoostikMartin - I'm trying to work throught it and understand it. Thanks. – Diane2 Jun 13 '13 at 15:23
  • Matt-Dot-net, I don't want to do that as it's an existing website with many pages and tries accessing the session many times in many different places. But thanks anyways. – Diane2 Jun 13 '13 at 15:25
  • doesn't seem to be working. I copied everything from your link and nothing is happening. – Diane2 Jun 13 '13 at 15:38
  • I have this link to expose the jwuery library - is that all I need? – Diane2 Jun 13 '13 at 16:00

0 Answers0