何らかの理由で、[名前を付けて保存]ダイアログを表示すると、チェックサムボックスが更新されません。ただし、以下のContent-Dispositionヘッダーコードをコメントアウトすると、すべて正常に機能します。何か案は?
protected void SubmitButton_Click(object sender, EventArgs e)
{
checksumField.Text = String.Empty;
FileInfo filename = this.CreateFileInfoFromInput();
if (!filename.Exists)
{
tableField.Focus();
tableField.BorderColor = System.Drawing.Color.Red;
return;
}
this.SaveFile(filename);
checksumField.Text = GetChecksum(filename);
}
private FileInfo CreateFileInfoFromInput()
{
/* blah */
return new FileInfo(blah);
}
private string GetChecksum(FileInfo filename)
{
return "test";
}
private void SaveFile(FileInfo fileName)
{
// Clear old headers
Response.Clear();
Response.Buffer = false;
// Set the ContentType and Headers
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName.Name); // <<<---- FAILING RIGHT HERE
Response.AppendHeader("Content-Length", fileName.Length.ToString(System.Globalization.CultureInfo.InvariantCulture));
Response.AppendHeader("Connection", "Keep-Alive");
// Send data
Response.TransmitFile(fileName.FullName);
}