zoukankan      html  css  js  c++  java
  • asp.net 生成静态页面

     
    先写一个类:
    public class ResponseFilter : Stream
        {
            private Stream m_sink;
            private long m_position;
            private FileStream fs;
            public ResponseFilter(Stream sink)
            {
                m_sink = sink;
                fs = new FileStream(@"C:\FilterOutput\Products.htm", FileMode.OpenOrCreate, FileAccess.Write);
            }
            // The following members of Stream must be overriden.
            public override bool CanRead
            { get { return true; } }
            public override bool CanSeek
            { get { return false; } }
            public override bool CanWrite
            { get { return false; } }
            public override long Length
            { get { return 0; } }
            public override long Position
            {
                get { return m_position; }
                set { m_position = value; }
            }
            public override long Seek(long offset, System.IO.SeekOrigin direction)
            {
                return 0;
            }
            public override void SetLength(long length)
            {
                m_sink.SetLength(length);
            }
            public override void Close()
            {
                m_sink.Close();
                fs.Close();
            }
            public override void Flush()
            {
                m_sink.Flush();
            }
            public override int Read(byte[] buffer, int offset, int count)
            {
                return m_sink.Read(buffer, offset, count);
            }
            // Override the Write method to filter Response to a file.
            public override void Write(byte[] buffer, int offset, int count)
            {
                //Write out the response to the browser.
                m_sink.Write(buffer, 0, count);
                //Write out the response to the file.
                fs.Write(buffer, 0, count);
            }
        }
     //把类调用到OnInit方法中
            #region OnInit
            /// <summary>
            /// 生成静态页
            /// </summary>
            /// <param name="e"></param>
            protected override void OnInit(EventArgs e)
            {
               Response.Filter = new ResponseFilter(Response.Filter);
            }
            #endregion
     
     
    来源于:www.hackbadboy.com   BadBoy网络安全小组  B.B.S.T信息安全团队
  • 相关阅读:
    javascript入门 之 zTree(十四 增删查改)(二)
    javascript入门 之 zTree(十四 增删查改)(一)
    javascript入门 之 zTree(十三 移动/复制事件)
    javascript入门 之 bind() (二)
    javascript入门 之 zTree(十二 托拽事件(二))
    javascript入门 之 zTree(十一 托拽事件(一))
    Java 使用 switch 语句和枚举类型
    微信公众号开发(四)—— 自定义菜单的创建
    微信公众号开发(三)——获取 Access_Token
    微信公众号开发(二)—— 图文消息
  • 原文地址:https://www.cnblogs.com/secbook/p/2654917.html
Copyright © 2011-2022 走看看