Careful when using rc:Toolbar=false

I'm in the middle of reinstalling Visual Studio, and so I thought I would share an interesting story from a couple of weeks ago.  An internal customer (Microsoft-speak for some other team at Microsoft) of Reporting Services was encountering seemingly random rsExecutionNotFound errors when navigating around their application.  Of course, things like this are never random and there was a perfectly good explanation.  After digging through their application for a little while, and with the help of Fiddler, I stumbled upon the problem.  They were rendering the same report in two different contexts, one of them was specifying rc:Toolbar=false, and the other wasn't.  Basically, their call to the report server looked something like this in the two places:

https://reports/reportserver/?/myreport&rs:Command=Render&rc:Toolbar=false

https://reports/reportserver/?/myreport&rs:Command=Render

Now, there is actually a subtle little problem with rendering using rc:Toolbar=false against the ReportServer virtual directory.  When this happens in a default installation, the Report Server sends a cookie back to IE to identify the session.  This cookie is then passed back to the report server to load up the appropriate snapshot, parameter, data source information, etc to view subsequent pages and images from the report.  What would happen is the user would navigate to the page where the report being rendered w/rc:Toolbar=false was sitting, which would give IE the cookie.  The user would navigate away from the page, and eventually head to the page where rc:Toolbar=false was not specified.  However, even in this case if the cookie is there, we try to use it to load the user session, which would fail because the session had timed out in the time between the two requests.  The user would be greeted with an "Execution Not Found" error message and would have to close and restart IE to get things working again.

The moral?  Don't render against the ReportServer virtual directory using rc:Toolbar=false unless you really know what you are doing, because it is tricky to get right.  If you want to render using the ReportServer virutal directory (so you don't have to roll your own Report Viewer Control ASP.Net application) then you should build a stylesheet which removes the toolbar, and use that.