FileInfo fi = new FileInfo (filename);//excelfile is the address of the file on the server
HttpResponse contextresponse = HttpContext.Current.Response;
Contextresponse.clear ();
Contextresponse.buffer = true;
Contextresponse.charset = "UTF8"; Set the type to Chinese to prevent garbled appearance
String downloadname = month. Replace ("/", "Year") + "monthly passenger equipment Facility maintenance Management table". xls ";
String broswer = context. Request.UserAgent.ToLower ();
if (broswer. IndexOf ("MSIE") >-1
|| Broswer. IndexOf ("Edge") >-1
|| Broswer. IndexOf ("like Gecko") >-1)
{
Downloadname = Httputility.urlpathencode (downloadname);
}
Contextresponse.appendheader ("Content-disposition", String.Format ("attachment;filename={0}", DownloadName)); Define output file and file name
Contextresponse.appendheader ("Content-length", fi. Length.tostring ());
contextresponse.contentencoding = Encoding.UTF8;
Contextresponse.contenttype = "Application/ms-excel";//Set Output file type to excel file.
HttpContext.Current.Server.UrlEncode ()
Contextresponse.writefile (FI. FullName);
Contextresponse.flush ();
Context.ApplicationInstance.CompleteRequest ();
Background Simulation Popup Upload Marina