所以这是我的问题:我有一个使用对 ExportFile 的响应的代码,但问题出在响应代码之后。随后的代码不再执行,或者它就像被读取但被忽略了。对不起,我是菜鸟。所以这是我的代码:
fullFilePath = "" + rootPath + "" + Filename + ".xlsx";
string fileName = fullFilePath.Substring(fullFilePath.LastIndexOf('\\') + 1);
byte[] buffer;
using (FileStream fileStream = new FileStream(fullFilePath, FileMode.Open))
{
int fileSize = (int)fileStream.Length;
buffer = new byte[fileSize];
// Read file into buffer
fileStream.Read(buffer, 0, (int)fileSize);
}
Response.Clear();
Response.Buffer = true;
Response.BufferOutput = true;
Response.ContentType = "application/x-download";
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.CacheControl = "public";
// writes buffer to OutputStream
Response.OutputStream.Write(buffer, 0, buffer.Length);
newFile.Delete();
ClientScript.RegisterStartupScript(GetType(), "id", "EnableCtrl()", true);
执行此操作后,不会触发或触发 javascript“EnableCtrl()”。当我删除与响应相关的代码部分并将其更改为其他内容时,将触发 javascript。那么我怎么能在响应代码之后运行 javascript 呢?