2017年4月26日 星期三

檔案下載


string sFile = @"c:\temp\ff.pdf";
WebClient wc = new WebClient();
byte[] b = wc.DownloadData(sFile);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment;filename=uu.pdf");
Response.BinaryWrite(b);
Response.End();

取得Client IP

P.S 僅Framkwork 3.5以上有效
string sHostName = System.Net.Dns.GetHostName();
string IP = Dns.GetHostEntry(sHostName).AddressList.First(o => o.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToString();