在实现sqlserver会话状态模式时在会话中存储图像时的序列化问题

时间:2011-09-19 14:11:50

标签: c# asp.net sql-server

我正在我的网站中将会话状态实现为sql server模式,此时我遇到了问题

public void setCoverImage()
        {
            DateTime dt = new DateTime();
            int dd = dt.Day;
            int mm = dt.Month;
            int yy = dt.Year;
            int hr = dt.Hour;
            int min = dt.Minute;
            int sec = dt.Second;
            int msec = dt.Millisecond;
            int tm = dd + mm + yy + hr + min + sec + msec;
            imgShowLogo.Src = "../../supportfiles/epub/cover.jpg?state=[" + tm + "]";
            //imgShowLogo.ImageUrl = "../../supportfiles/epub/cover.jpg?state=[" + tm + "]";
            Session["BookLogo"] = imgShowLogo;
        }

我在这里遇到问题

"Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode. "

请尽快帮助我,并提前致谢。

1 个答案:

答案 0 :(得分:1)

好吧,我认为只保存会话中的图片网址,而不是整个图像。