具体来说,我们正在使我们的应用程序与进程外会话状态服务器兼容,其中保存在会话中的所有类型都必须是可序列化的。
有没有办法在编译时查看放入 HttpSessionState 的任何类型都标记有 Serializable 属性。类似于此“无效”代码的内容
public static void Put<T>( string key, T value ) where T : IsMarkedWitheSerializableAttribute
{
HttpContext.Current.Session[key] = value;
}