保存在会话变量中的结构

发布于 2024-08-11 23:27:17 字数 394 浏览 1 评论 0原文

ReportInfo 是一个结构体。该结构在一个网页上运行良好,但我试图在另一个网页上使用它。这里是我将 ReportInfo 结构保存到会话变量的地方

Session["ReportInfo"] = reportInfo;

在另一个网页上,我重新创建了结构,然后将会话变量分配给它,如下所示...

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

我收到以下运行时错误:

System.InvalidCastException 未由用户代码处理 Message="指定的演员阵容无效。" Source="App_Web_-s8b_dtf"

如何从 Session 变量中获取 ReportInfo 结构以再次使用?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡淡绿茶香 2024-08-18 23:27:17

您检查过 Session["ReportInfo"] 的值吗?也许它是 null 或其他一些令人讨厌的值?另外,我假设第二页中的 reportInfoReportInfo 类型?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文