我可以编写什么ASP.NET页面生命周期事件来确定发送的视图状态的大小?此外,是否可以在不解析渲染的HTML(如页面对象上的属性)的情况下确定大小,还是解析唯一的方法?
我想要做的是记录尺寸,特别是如果它们超过某个阈值.
解决方法
您可以继续编写viewstate函数SavePageStatetoPersistenceMedium.这个函数也用于压缩视图状态…
例如…
public abstract class BasePage : System.Web.UI.Page { private ObjectStateFormatter _formatter = new ObjectStateFormatter(); protected override void SavePageStatetoPersistenceMedium(object viewState) { MemoryStream ms = new MemoryStream(); _formatter.Serialize(ms,viewState); byte[] viewStateArray = ms.ToArray(); .... } }
一些参考.
http://www.codeproject.com/KB/viewstate/ViewStateCompression.aspx
http://forums.asp.net/p/1139883/3836512.aspx
http://www.dotnetcurry.com/ShowArticle.aspx?ID=67&AspxAutoDetectCookieSupport=1
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。