[Mono-list] .Net output works in XSP2 not Apache2/mod_mono
Joseph Kondel
joe at joekondel.com
Thu Jul 3 05:34:26 EDT 2008
Hi,
I've got some file download code that works just fine under XSP2
( outputs the file ok, and user can open it up ) but under Apache2/
Mod_Mono (Apache/2.2.4 (Ubuntu 7.10)) mod_mono/1.2.6) it truncates
the file to zero. I've checked permissions, etc... and can't seem to
come up with any ideas as to why this is. There's no errors in the
logs either.
File output code is:
private bool DownloadFile(string sFileId)
{
bool bRetValue = false;
try
{
FileService FService = new FileService();
FileStorage DownloadFile = FService.GetFileById
(Int16.Parse(sFileId));
string sFileName = pGeneral.GetBaseFilePath() + "\\" +
DownloadFile.Path;
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
this.EnableViewState = false;
Response.Buffer = true;
Response.ContentType = "application/octet-stream";
Response.Charset = "utf-8"; //UTF8
Response.AddHeader("Content-Disposition", "attachment;
filename=" + DownloadFile.FileName);
FileStream sourceFile = new FileStream(sFileName,
FileMode.Open);
long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getContent);
Response.Flush();
bRetValue = true;
// Response.End();
}
catch
{
bRetValue = false;
}
return bRetValue;
}
Thanks,
-j
More information about the Mono-list
mailing list