views:

588

answers:

2

To keep things simple, we have a few aspx pages...

Page1.aspx - resets Session information.
Page2.aspx - Search form with results and sets Session variables.
Page3.aspx, Page4.aspx, Page5.aspx - require Session variables set on Page2.aspx

What we're finding is that as Page2.aspx loads and setting the Session variables, Page1.aspx is being called and resetting the Session. However, Page1.aspx shows up in the browser, not Page2.aspx. We were only able to find this happening as we stepped through the code and put break points in the Page_Load events for Page1.aspx and Page2.aspx and were surprised to see Page2.aspx being processed as soon as Page1.aspx stopped processing on the server.

Possibly useful info... we do use a Master page and there are links to Page1.aspx in the Master page. Other than that, I can not find any references to Page1.aspx in the code base.

update:
It may be due to authentication? It appears that when I access Page2.aspx, the server is possibly authenticating again on Page1.aspx? Is that typical?

A: 

Launch Fiddler and run the application normally. It will tell you the traffic that is occurring and identify what pages are redirecting to other pages. Once you know the path, you can identify why that path exists by investigating the source code.

It's possible that your application domain is recycling and thus, all the session variables are lost and you probably have code the redirects the visitor if the session variables are missing, right?

If this is the case, as quick fix, you can use the StateServer or store your session variables in Sql Server. Your application domain shouldn't be recycling every minute, but it could cause the behavior you see if you're storing sessions "in process", which is the default.

AndrewDotHay
+1  A: 

Thanks for the tip Andrew.

We figured out what was going on... Page1.aspx in the application is really Default.aspx. On Page2.aspx, another developer put a img tag on the page that did not have src property defined. So when Page2.aspx executed, it was looking for an image located at the web site's root level, this then triggered the code on Default.aspx (Page1) and wipe away the session.

Overall it looked something like this...

On Page2.aspx

<img src=""> <!-- this ended up triggering a call to Default.aspx, wiping the session -->

Hopefully that helps out someone else.

proudgeekdad