473,326 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Help with streaming binary content to Safari

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/Vie...ype=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();
Jun 27 '08 #1
3 3977
Hi Brad,

From your description, you're using an ASP.NET web page to stream out some
binary files. And you found that the streaming page work will for IE and
firefox, but failed with some error when be visited by Safari browser,
correct?

From the code snippet you provided, the streaming code look correct. Also,
I've performed some tests on the public page you provided. I've tried all
the following browsers on windows system:

** IE7
**FireFox 2.0
**Safari 3.1.1

All the test works correctly(display the PDF file in browser). therefore,
I think the problem should be something specific to the client-side machine
or the network enviornmente. Have you tried accessing from multiple client
machine to see the behavior?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Reply-To: "Brad" <la**@newsgroup.nospam>
From: "Brad" <la**@newsgroup.nospam>
Subject: Help with streaming binary content to Safari
Date: Mon, 2 Jun 2008 17:47:37 -0700
>
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/Vie...ype=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();
Jun 27 '08 #2
Hi Brad,

Have you got any progress on this issue? Have you further verify whether
the problem is specific to the parituclar client machine? If there is
anything else we can help, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: st*****@online.microsoft.com (Steven Cheng [MSFT])
Organization: Microsoft
Date: Tue, 03 Jun 2008 05:33:57 GMT
Subject: RE: Help with streaming binary content to Safari
>Hi Brad,

From your description, you're using an ASP.NET web page to stream out some
binary files. And you found that the streaming page work will for IE and
firefox, but failed with some error when be visited by Safari browser,
correct?

From the code snippet you provided, the streaming code look correct. Also,
I've performed some tests on the public page you provided. I've tried all
the following browsers on windows system:

** IE7
**FireFox 2.0
**Safari 3.1.1

All the test works correctly(display the PDF file in browser). therefore,
I think the problem should be something specific to the client-side
machine
>or the network enviornmente. Have you tried accessing from multiple client
machine to see the behavior?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

================================================= =
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ault.aspx#noti
f
>ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================= =
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>>Reply-To: "Brad" <la**@newsgroup.nospam>
From: "Brad" <la**@newsgroup.nospam>
Subject: Help with streaming binary content to Safari
Date: Mon, 2 Jun 2008 17:47:37 -0700
>>
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/Vie...ype=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();

Jun 27 '08 #3
I updated Adobe on the Mac and still the same problem. But I found the public site code was actually different from the
snippet I included in the original post. I updated a test site with code to match my post and it worked so I have
since updated the public site with that code as it work with the Mac: the difference was the old code just did a
response.close at the end and the new code does the response.flush and response.end.
But if I understood you tested the link I provided with Safari and it worked for you (same version of Safari as I have)
before I did these updates. I would have expected that it would not have worked for you until these updates.
Brad

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message news:R7**************@TK2MSFTNGHUB02.phx.gbl...
Hi Brad,

Have you got any progress on this issue? Have you further verify whether
the problem is specific to the parituclar client machine? If there is
anything else we can help, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>>From: st*****@online.microsoft.com (Steven Cheng [MSFT])
Organization: Microsoft
Date: Tue, 03 Jun 2008 05:33:57 GMT
Subject: RE: Help with streaming binary content to Safari
>>Hi Brad,

From your description, you're using an ASP.NET web page to stream out some
binary files. And you found that the streaming page work will for IE and
firefox, but failed with some error when be visited by Safari browser,
correct?

From the code snippet you provided, the streaming code look correct. Also,
I've performed some tests on the public page you provided. I've tried all
the following browsers on windows system:

** IE7
**FireFox 2.0
**Safari 3.1.1

All the test works correctly(display the PDF file in browser). therefore,
I think the problem should be something specific to the client-side
machine
>>or the network enviornmente. Have you tried accessing from multiple client
machine to see the behavior?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

================================================ ==
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ault.aspx#noti
f
>>ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================ ==
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>>>Reply-To: "Brad" <la**@newsgroup.nospam>
From: "Brad" <la**@newsgroup.nospam>
Subject: Help with streaming binary content to Safari
Date: Mon, 2 Jun 2008 17:47:37 -0700
>>>
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/Vie...ype=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();

Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Markus Ernst | last post by:
Hi I know this question is rather HTTP related than PHP, but I did not find an HTTP group on my news server. I deliver some files with the following PHP syntax: header('Content-Description:...
3
by: James Whitehead | last post by:
I have the following code which works fine downloading smaller files, the trouble is most of the files to be downloaded are large. With large files it just returns a HTTP 500 error. Any ideas...
1
by: Daniel | last post by:
streaming random filetypes from .aspx how to stream a file from inside a .aspx? e.g. so one could go href="./foo.aspx?file=bar.mp3" or href="./foo.aspx?foo.dat" etc. preferabley i would like...
3
by: Ipsita | last post by:
Hi! I am trying SOAP with DIME attachments in web services. For example say, I have a file resume.pdf stored somewhere on my server. How does the web service send the file to the client, so that...
2
by: Stu | last post by:
Hi, I have encrypted pdf files which I need to stream through a web service to the browser. So I have a byte() array returned from my web service call which allows me to decrypt back to the pdf...
1
by: DB | last post by:
Hi All, Iā€™m trying to stream a PDF with .NET 2.0 in a c# web app. However, it does not actually show the PDF (using adobe acrobat). The Situation: Click on a Button, Opens a new Window,...
5
by: Manuel Alves | last post by:
Hi, Is it possible to store media files (like windows .wmv) on SQL Server 2005 and stream it back to the client via media server (not just download it)? Regards, Manuel Alves
7
by: Douglas McCormick | last post by:
Hello, I am looking for the best way to securely stream a PDF to the browser (IE). The PDF would be inside our firewall, so presumably there would have to be some sort of middle-tier app inside...
1
by: Faisal Shafiq | last post by:
I want to upload a file direct to the Silverlight Streaming Service from a Web Client such as silverlight application. As per our product requirement we want to upload a .WMV file directly from...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.