471,594 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 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 3832
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Markus Ernst | last post: by
3 posts views Thread by James Whitehead | last post: by
1 post views Thread by Daniel | last post: by
1 post views Thread by DB | last post: by
5 posts views Thread by Manuel Alves | last post: by
7 posts views Thread by Douglas McCormick | last post: by
1 post views Thread by Faisal Shafiq | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

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.