B
Brad
I have an aspx page that is sending pdf files to client browsers: it uses a filestream to read the pdf file and
response.binarywrite to send content to the browser. This has worked great for years in IE, Firefox and Opera on
windows, and it works on a Mac with Firefox and Opera. But this fails in Safari with the generic message "A network
error occurred while accessing this document".
Here is a link to try out http://www.lanecounty.org/TaxMap/ViewFile.aspx?type=TM&id=2380
Here is a code snippet for the page.
switch (fi.Extension.ToLower())
{
case ".tif":
case ".tiff":
contentType = "image/tiff";
break;
case ".pdf":
contentType = "application/pdf";
break;
}
//########################################
FileStream fs = new FileStream(imageFile, FileMode.Open);
try
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentType = contentType;
int FileLength = System.Convert.ToInt32(fs.Length);
byte[] buffer = new byte[FileLength + 1];
fs.Read(buffer, 0, FileLength);
HttpContext.Current.Response.BinaryWrite(buffer);
}
catch (Exception ex)
{
}
finally
{
fs.Close();
}
//########################################
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
response.binarywrite to send content to the browser. This has worked great for years in IE, Firefox and Opera on
windows, and it works on a Mac with Firefox and Opera. But this fails in Safari with the generic message "A network
error occurred while accessing this document".
Here is a link to try out http://www.lanecounty.org/TaxMap/ViewFile.aspx?type=TM&id=2380
Here is a code snippet for the page.
switch (fi.Extension.ToLower())
{
case ".tif":
case ".tiff":
contentType = "image/tiff";
break;
case ".pdf":
contentType = "application/pdf";
break;
}
//########################################
FileStream fs = new FileStream(imageFile, FileMode.Open);
try
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentType = contentType;
int FileLength = System.Convert.ToInt32(fs.Length);
byte[] buffer = new byte[FileLength + 1];
fs.Read(buffer, 0, FileLength);
HttpContext.Current.Response.BinaryWrite(buffer);
}
catch (Exception ex)
{
}
finally
{
fs.Close();
}
//########################################
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();