[HttpGet]
public FilePathResult ExportResult(int? AssetType, string aName, int? AssetStatus, int? Auditok, int? BackStatus)
{
Hashtable ht = new Hashtable { { "AKinderGartenId", User.KindergartenId } };
ht["AssetType"] = AssetType;
if (aName != null && !string.IsNullOrEmpty(aName.Trim()))
{
ht["AssetName"] = aName.Trim();
}
ht["AssetStatus"] = AssetStatus;
ht["Auditok"] = Auditok;
ht["BackStatus"] = BackStatus;
IList<Hashtable> result = AssetRecordsBLL.GetAssetRecordsAll(ht);
List<string> colNames = new List<string>
{
"编号","分类","名称","使用说明","学校","使用状态","数量","发生日期","归还日期","使用 者","登记者","审核状态","归还状态"
};
string[] colNameInString = { "AssetIdCust", "TypeName", "AssetName", "Description", "KindergartenName", "StatusType", "AssetCount", "AssetDate", "BackDate", "Truename", "RecorderName", "Auditok", "BackStatus" };
string filename = Excel.DataToExcel("本园资材使用记录", colNames, result, colNameInString);
return File(filename, "application/vnd.ms-excel",Url.Encode("本园资材使用记录.xls"));
}
在点击按钮后,使用IE下载的时候完全正常,但是使用迅雷下载的时候文件的名称不对,名称是“ExportResult”,这是我的方法名,而且没有后缀名。请问下这个问题怎么解决??
public FilePathResult ExportResult(int? AssetType, string aName, int? AssetStatus, int? Auditok, int? BackStatus)
{
Hashtable ht = new Hashtable { { "AKinderGartenId", User.KindergartenId } };
ht["AssetType"] = AssetType;
if (aName != null && !string.IsNullOrEmpty(aName.Trim()))
{
ht["AssetName"] = aName.Trim();
}
ht["AssetStatus"] = AssetStatus;
ht["Auditok"] = Auditok;
ht["BackStatus"] = BackStatus;
IList<Hashtable> result = AssetRecordsBLL.GetAssetRecordsAll(ht);
List<string> colNames = new List<string>
{
"编号","分类","名称","使用说明","学校","使用状态","数量","发生日期","归还日期","使用 者","登记者","审核状态","归还状态"
};
string[] colNameInString = { "AssetIdCust", "TypeName", "AssetName", "Description", "KindergartenName", "StatusType", "AssetCount", "AssetDate", "BackDate", "Truename", "RecorderName", "Auditok", "BackStatus" };
string filename = Excel.DataToExcel("本园资材使用记录", colNames, result, colNameInString);
return File(filename, "application/vnd.ms-excel",Url.Encode("本园资材使用记录.xls"));
}
在点击按钮后,使用IE下载的时候完全正常,但是使用迅雷下载的时候文件的名称不对,名称是“ExportResult”,这是我的方法名,而且没有后缀名。请问下这个问题怎么解决??
byte[] buffer = new byte[f.Length];
f.Read(buffer, 0, buffer.Length);
f.Close();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("", System.Text.Encoding.UTF8));
Response.BinaryWrite(buffer);
Response.Flush();
Response.End(); 参考