4

I have a Session object in my asp.net app that I am setting to the userID value. The session object gets instantiated in the gloal.asax. The value is being set on a button_click event when a user signs in and has been authenticated.

However, somewhere somehow in my app, the Session is being set to Empty. How can I determine where and how the session object is being set to empty?

1
  • Can you post the code that is in the global.asax? Usually, session would not need to be instantiated. Commented Aug 19, 2012 at 20:54

2 Answers 2

3

Do a global search for the session variable within your project. Put a break point on all of the lines. and then closely step through the application. I just had the same bug two days ago. Took four hours stepping through 80+ pages. Good luck.

Sign up to request clarification or add additional context in comments.

Comments

1

A couple of reasons this may happen:

  • Are you modifying the variable on Page_Load()?
  • Is your browser returning the session cookie? (You can verify using Fiddler)

In my experience this kind of problem will almost certainly be addressed by the above.

6 Comments

Not on the page_load. I do have it in the global.asax session_start and then on button_click events is where the session value is being written or read from.
Also make sure the session ID isn't changing from when you create the variable in session_start to when you are trying to retrieve it in the click event.
Ok I would double check what you've got in your global.asax, and that it isn't running for each request.
@m.edmondson I verified that the global.asax line is only being called when I launch the application.
@JeffSiver I am certain the session ID is not changing
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.