ASP.NET 显示项目之外的图片

1.<asp:Image>标签的使用Loginer.images是图片的路径

   this.images.ImageUrl = "showImg.aspx?imgFile="+ Loginer.images;

2.添加一个新的页面showImg.aspx,在后台代码写

 private string file = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            file = Request.QueryString["imgFile"].ToString();
            FileStream stream = new FileStream(file, FileMode.Open);
            //获取流的的长度
            long FileSize = stream.Length;

            byte[] Buffer = new byte[(int)FileSize];
            stream.Read(Buffer, 0, (int)FileSize);
            stream.Close();
            Response.BinaryWrite(Buffer);
            stream = null;

        }

显然这是把他当做一种请求处理的

posted @ 2014-01-27 16:51  aswater  阅读(312)  评论(0编辑  收藏  举报