Вывод файла в поток браузера

nKognito
Дата: 07.06.2008 18:15:31
Народ всем привет. Сделал страничку, при вызове которой должно появится диалоговое окно сохранения файла. Вот код:HttpResponse fileResponse = HttpContext.Current.Response;
fileResponse.AddHeader("pragma", "no-cache");
fileResponse.AddHeader("cache-control", "private");
fileResponse.CacheControl = "no-cache";
fileResponse.ContentType = "application/octet-stream";
fileResponse.AddHeader("Content-Disposition",
"attachment; filename=" + HttpUtility.UrlEncode(Context.Request.ContentEncoding.GetBytes(fileName)));

FileStream fs = System.IO.File.OpenRead(fileName);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fileResponse.OutputStream.Write(buffer, 0, buffer.Length);
fileResponse.End();

Вылетает на последней строке (там где End()) и пишет:
[System.Threading.ThreadAbortException] = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}
Никто не сталкивался? Спасибо.
nKognito
Дата: 07.06.2008 18:36:23
Вопрос снят!