之前好好的 code 因為 Server 搬家後,莫名不能用 ,原本的 code 大概是這樣
workbook.Write(file); file.Close(); Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=" + Server.UrlEncode(CurrDate.ToString("yyyyMMddHHmmss") + ".xls")); Response.AddHeader("Transfer-Encoding", "identity"); //設定MIME 標頭 //可以參考 http://baike.baidu.com/view/160611.htm Response.ContentType = "application/octet-stream"; Response.BinaryWrite(File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + "xls/" + guid + ".xls")); Response.Flush(); Response.Close();
在 localhost 會正常,上正式機器後,就出現 失敗 – 網路錯誤