Structure Saved in a Session Variable
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-t开发者_如何学Cime 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?
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
?
精彩评论