views:

109

answers:

1

The ReportInfo is a structure. The structure works fine on one web page but I am trying to use it on another web-page. Here is where I saved the ReportInfo structure to the Session Variable

Session["ReportInfo"] = reportInfo;

On the other web-page, I re-created the Structure and then assign the session variable to it, like this...

reportInfo = (ReportInfo)(Session["ReportInfo"]);

I get the following run-time error:

System.InvalidCastException was unhandled by user code Message="Specified cast is not valid." Source="App_Web_-s8b_dtf"

How do I get the ReportInfo structure out of the Session variable to use again?

A: 

Have you checked the value of Session["ReportInfo"]? Perhaps it's null or some other unsavory value? Also, I assume reportInfo in the second page is of type ReportInfo?

Traveling Tech Guy
The of Session["ReportInfo"] is what it should be on the original page... But I cannot tell what the value is once on the new page...
Lakeshore
So you have an issue with your session persistence, not the cast itself. Check other session object and/or your IIS settings
Traveling Tech Guy