views:

229

answers:

4

Hi,

I am having trouble with debugging one of the problems that I am having in our website. This is the problem. I have a webpage that contains the photo of an employee and information related to the employee. When the user logins to our website, we are storing the details of the employee in session. I am setting the image url for the photo of an employee as follows.

imgEEPhoto.ImageUrl = imgPhoto.aspx?Company=XXXX&Empno=YYYY.

Inside the page imgPhoto.aspx, I am checking if the session is alive for that user. when I login to the page that has the employee photo sometimes the photo is not displayed. It is because I am checking whether the session is alive inside the imgPhoto.aspx page. sometimes the session is alive and sometimes the session is not alive. It looks like there is some function that is setting the session to null asynchronously. I am not knowing how to track that function. so I am thinking that inside the imgPhoto.aspx page, if I can get the list of all functions that have been executed so far, I could track the function that is resetting the session. Is there a way to find this?

If there is no another way to debug this problem, please let me know.

Thanks, sridhar.

A: 

There's no built-in facility in .NET to list all functions called, although you can print the call-stack at a specific point (like exceptions do).

I'd suggest looking for a code-coverage profiler if this is the route you want to take.

U62
A: 

If I understand the problem, the imgphoto.aspx is building a string that contains a url and then sending it back, correct? If so, if you modified imgPhoto.aspx to always return a hard-coded URL for an image that you know defintely exists, do you still have the problem?

I'd want to first rule out that somehow you are not inadvertently sending back a malformed url, or the url for a photo that does not exist. I'd try this first, without checking the session, and if you can't reproduce the problem (i.e. that always works), then add the session checks and still send back a static url and see if the problem can be duplicated that way.

I always try to rule out the 'easy' things first - maybe you have already done that?

EJB
A: 

It sounds as though you problem is intermittent, perhaps your session state is timing out? You could log when the session ends in the Gloabal.asax files Session_End method to find out exactly when the session is terminated. You could try increasing the Session timeout (the default is 20 minutes) resolution like this:

The Timeout property can be set in the Web.config file

<SessionState timeout = "30" />

or, you can set the Timeout property value directly using application code

Session.Timeout = 30
Phaedrus
I am using the session on the main page and also on imgPhoto page. If it times out, it should give error on the main page. But it is not giving any error. I checked the session after each function the page calls and the session is alive in all functions.
A: 

The page imgPhoto.aspx gets company and empno as query string parameters. Then the page gets the binary data based on company and empno and uses Response.BinaryWrite() to display photo. The session check is at the beginning of this function. so somewhere before this function is called and after the end of all the functions in mainpage the session is getting timedout. Actually I am not sure if it is getting timedout because I can print the sessionid. But I cannot access variables stored in session.

If I print the callstack inside the function, it is giving the list of functions that are executed inside that page. It is not giving all the functions that are executed before that function.

Thanks, sridhar.