ASP.NET 顯示項目以外的圖片

1.<asp:Image>標籤的使用Loginer.images是圖片的路徑this

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

2.添加一個新的頁面showImg.aspx,在後臺代碼寫code

 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;

        }

顯然這是把他當作一種請求處理的blog

相關文章
相關標籤/搜索