public override void Write(Byte[] buffer, int offset, int count) { Byte[] data = SevenZipSharpHelper.Compress(buffer); String txt = Convert.ToBase64String(data, Base64FormattingOptions.InsertLineBreaks); data = Encoding.UTF8.GetBytes(txt); deflateStream.Write(data, 0, data.Length); }
/// <summary> /// 保存页面状态 /// </summary> public override void Save() { if (ViewState != null || ControlState != null) { Pair data = new Pair(ViewState, ControlState); //序列化,压缩 String strbase64 = new ObjectStateFormatter().Serialize(data); String strzip = SevenZipSharpHelper.Compress(strbase64); //把页面状态注册到页面上 Page.ClientScript.RegisterHiddenField(STATEKEY, strzip); } }
public override void OnActionExecuted(HttpActionExecutedContext context) { HttpResponseMessage Response = context.Response; HttpContent content = Response.Content; Byte[] buffer = content == null ? new Byte[0] : content.ReadAsByteArrayAsync().Result; buffer = SevenZipSharpHelper.Compress(buffer); Response.Content = new ByteArrayContent(buffer); //Response.Content.Headers.Add("Content-encoding", "7z"); Response.Content.Headers.Remove("Content-Type"); Response.Content.Headers.Add("Content-Type", "application/octet-stream"); base.OnActionExecuted(context); }
public override void Write(Byte[] buffer, int offset, int count) { Byte[] data = SevenZipSharpHelper.Compress(buffer); deflateStream.Write(data, 0, data.Length); }