Help with streaming binary content to Safari

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();
 
S

Steven Cheng [MSFT]

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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
Reply-To: "Brad" <[email protected]>
From: "Brad" <[email protected]>
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/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();
 
S

Steven Cheng [MSFT]

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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: (e-mail address removed) (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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
Reply-To: "Brad" <[email protected]>
From: "Brad" <[email protected]>
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/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();
 
B

Brad

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 said:
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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: (e-mail address removed) (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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
Reply-To: "Brad" <[email protected]>
From: "Brad" <[email protected]>
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/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();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top