473,544 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.binary write 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.T oLower())
{
case ".tif":
case ".tiff":
contentType = "image/tiff";
break;
case ".pdf":
contentType = "applicatio n/pdf";
break;
}

//############### ############### ##########
FileStream fs = new FileStream(imag eFile, FileMode.Open);
try
{
HttpContext.Cur rent.Response.C lear();
HttpContext.Cur rent.Response.B uffer = true;
HttpContext.Cur rent.Response.C ontentType = contentType;

int FileLength = System.Convert. ToInt32(fs.Leng th);
byte[] buffer = new byte[FileLength + 1];
fs.Read(buffer, 0, FileLength);
HttpContext.Cur rent.Response.B inaryWrite(buff er);

}
catch (Exception ex)
{
}
finally
{
fs.Close();
}
//############### ############### ##########
HttpContext.Cur rent.Response.F lush();

HttpContext.Cur rent.Response.E nd();
Jun 27 '08 #1
3 4002
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(displ ay 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****@microsof t.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.binar ywrite 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.T oLower())
{
case ".tif":
case ".tiff":
contentType = "image/tiff";
break;
case ".pdf":
contentType = "applicatio n/pdf";
break;
}

//############### ############### ##########
FileStream fs = new FileStream(imag eFile, FileMode.Open);
try
{
HttpContext.Cur rent.Response.C lear();
HttpContext.Cur rent.Response.B uffer = true;
HttpContext.Cur rent.Response.C ontentType = contentType;

int FileLength = System.Convert. ToInt32(fs.Leng th);
byte[] buffer = new byte[FileLength + 1];
fs.Read(buffer, 0, FileLength);
HttpContext.Cur rent.Response.B inaryWrite(buff er);

}
catch (Exception ex)
{
}
finally
{
fs.Close();
}
//############### ############### ##########
HttpContext.Cur rent.Response.F lush();

HttpContext.Cur rent.Response.E nd();
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****@microsof t.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(displ ay 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****@microso ft.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.bina rywrite 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.T oLower())
{
case ".tif":
case ".tiff":
contentType = "image/tiff";
break;
case ".pdf":
contentType = "applicatio n/pdf";
break;
}

//############### ############### ##########
FileStream fs = new FileStream(imag eFile, FileMode.Open);
try
{
HttpContext.Cur rent.Response.C lear();
HttpContext.Cur rent.Response.B uffer = true;
HttpContext.Cur rent.Response.C ontentType = contentType;

int FileLength = System.Convert. ToInt32(fs.Leng th);
byte[] buffer = new byte[FileLength + 1];
fs.Read(buffer, 0, FileLength);
HttpContext.Cur rent.Response.B inaryWrite(buff er);

}
catch (Exception ex)
{
}
finally
{
fs.Close();
}
//############### ############### ##########
HttpContext.Cur rent.Response.F lush();

HttpContext.Cur rent.Response.E nd();

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.comw rote in message news:R7******** ******@TK2MSFTN GHUB02.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****@microsof t.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])
Organizatio n: 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(displ ay 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****@micros oft.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
professiona l 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.bin arywrite 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.T oLower())
{
case ".tif":
case ".tiff":
contentType = "image/tiff";
break;
case ".pdf":
contentType = "applicatio n/pdf";
break;
}

//############### ############### ##########
FileStream fs = new FileStream(imag eFile, FileMode.Open);
try
{
HttpContext.Cur rent.Response.C lear();
HttpContext.Cur rent.Response.B uffer = true;
HttpContext.Cur rent.Response.C ontentType = contentType;

int FileLength = System.Convert. ToInt32(fs.Leng th);
byte[] buffer = new byte[FileLength + 1];
fs.Read(buffer, 0, FileLength);
HttpContext.Cur rent.Response.B inaryWrite(buff er);

}
catch (Exception ex)
{
}
finally
{
fs.Close();
}
//############### ############### ##########
HttpContext.Cur rent.Response.F lush();

HttpContext.Cur rent.Response.E nd();

Jun 27 '08 #4

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

Similar topics

7
5436
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: File Transfer'); header('Content-Type: '.$mimetype); header('Content-Length: '.filesize($file));
3
12644
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 how to get this to work. I have tried to split the download into chunks but it just timesout. Set objFile = objFSO.GetFile(strFileName) '-- first...
1
1424
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 all file types to open with "save as" when href clicked
3
5097
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 the client can store it and also read from it. I am trying out with C# and ASP.NET. Server Side Web Method: -----------------------
2
6070
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 before displaying. It works but is slow when the average report is 84K. So basically I need to speed up the streaming. I have tried gzip...
1
5383
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, which generates a PDF, then streams it out to the client. (So the can get the window of acrobate, isnide of IE).
5
3238
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
9893
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 the firewall that would receive a request from a browser and then get the PDF and stream it outside the firewall to the browser. Does that make...
1
2835
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 silverlight client to Silverlight streaming service. I tried to user WebClient and HttpWebRequest for that purpose but, unfortunately I can found...
0
7632
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7783
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7392
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7720
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5309
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4930
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3422
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.