Response.WriteBinary problem.

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I've been working on a small page that allows my users to publish and
retrieve documents from a SQL database. Everything appears to be
working fine with exception of 2 things.

1.) Any file that can be opened and edited with the NotePad, once the
file has been uploaded to the SQL Server, when it's retrieved it has
the HTML for the web page I'm retrieving the file with. Below is an
example of a text file that I uploaded.

File Content Example:

This lline was entered in the *.txt file before uploading. Everything
below this was added when retrieving from SQL.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
Untitled Page
</title>
<link href="App_Themes/j....

End Example



2.) Office 2007 format documents retrieve as being corrupt.



Is Response.WriteBinary the proper way to do this...and if so, can you
give me some insite as to where I might be able to fix this problem?

Any help would be greatly appreciated.
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

From where are you making the call to the HttpResponse.WriteBinary method?

If you make the call from the code-behind of an ASPX-page (so it seems),
you might need to place the call between a Response.Clear() and a
Response.End(), to be sure that no markup is added to your output.

Example:

Response.Clear();
Response.WriteBinary(data);
Response.End();
 
Back
Top