Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Problem with webclient.downloaddata

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gom - 10 Dec 2007 21:15 GMT
I am using the following code to stream a server generated pdf file to a
client.  Acrobat 7 opens the file as expected but Acrobat 5,6 and 8 launch
in memory but never open.  I ran the command with Fiddler running and it
tells me there is a content-length mismatch of 129 bytes between my buffer
length and what the server actually sends.  I'm wondering if this is an
issue related to some additional header information or something that is
sent along with the buffer.  Can anyone help me with this?

Thanks in advance.

Dim client As New System.Net.WebClient()
Dim buffer As Byte() = client.DownloadData("http://www.mywebsite.com" &
myResponseString.ToString)

If buffer IsNot Nothing Then
 Response.ContentType = "application/pdf"
 Response.AddHeader("content-length", buffer.Length.ToString())
 Response.BinaryWrite(buffer)
End If
bruce barker - 10 Dec 2007 21:47 GMT
try:

  Response.ClearHeaders()
  Response.ClearContent()
  Response.ContentType = "application/pdf"
  Response.AddHeader("content-length", buffer.Length.ToString())
  Response.AddHeader("content-disposition","inline;filename=report.pdf")
  Response.BinaryWrite(buffer)
  Response.End()

-- bruce (sqlwork.com)

> I am using the following code to stream a server generated pdf file to a
> client.  Acrobat 7 opens the file as expected but Acrobat 5,6 and 8 launch
[quoted text clipped - 15 lines]
>   Response.BinaryWrite(buffer)
> End If
gom - 10 Dec 2007 21:59 GMT
Tried it and it made the length mismatch smaller but still the same basic
problem.
> try:
>
[quoted text clipped - 29 lines]
>>   Response.BinaryWrite(buffer)
>> End If
Peter Bromberg [C# MVP] - 11 Dec 2007 18:23 GMT
You need to examine the Response Stream (converted to text) to determine
exactly what is being added to the front of the response. Does the ASPX page
that generates this have anything besides the @Page Directive? If it does,
remove the offending markup.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com 

> Tried it and it made the length mismatch smaller but still the same basic
> problem.
[quoted text clipped - 31 lines]
> >>   Response.BinaryWrite(buffer)
> >> End If

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.