Re: Serve up file from outside web application directory

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thanks for your followup Brian,

for the text file with "System.Byte[]" problem you mentioned, do you mean
the file download dialog display the filename as "System.Byte[]"?

If this is the case, I suggest you check the code to see whether you have
add the "Content-Disposition" header and supply the filename. Because when
you stream out a file(or other binary content), the ASP.Net won't care
what's their original filename, you need to explicitly supply them.e.g.

======================
protected void Page_Load(object sender, EventArgs e)
{
byte[] bytes = null;
string path = @"d:\filestore\pdf_files\test.pdf";

bytes = File.ReadAllBytes(path);

Response.ClearHeaders();
Response.ClearContent();
Response.ContentType= "text/plain";

//here put the filename
Response.AddHeader("Content-disposition", "attachment;
filename=test.txt");

Response.Write(bytes);
Response.End();
}
===========

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


.



Relevant Pages

  • Re: Help with find and replace macro
    ... It is now replacing the header. ... Before I had FILENAME and DATE in the header. ... Also, if I have just a footer, it will replace in the footer. ...
    (microsoft.public.word.vba.general)
  • Re: Help with find and replace macro
    ... Firstly you are now saying that it works in the Header and Body whereas before it was only in the Body - has that change occurred? ... I have inserted the word FILENAME in the main text, ... I have cut and pasted the below simplified code for sub Test into the Visual ... I then used the debug menu and placed the cursor at the next MyStoryRange ...
    (microsoft.public.word.vba.general)
  • RE: Attachments of incoming mails missing, Exchange 2k3
    ... On the Firebox, I have Content Type set to ALLOW for anything that I want to ... I suppose it's possible but stripping the attachment for just one user seems ... he also said it may be insecure to allow that filename for ips ... For me, those header types were: ...
    (microsoft.public.exchange.admin)
  • Re: Rules - Moving Mail with an Attachment
    ... View a header of the messages - does it include the filename in the header? ... Teach Yourself Outlook 2003 in 24 Hours ... >> | by the anti-virus software. ...
    (microsoft.public.outlook)
  • Re: Help with find and replace macro
    ... I just did a very simple test - new document, typed FILENAME into the three places, cut and pasted and ran your code. ... header and footer have the word ... For Each myStoryRange In ActiveDocument.StoryRanges ...
    (microsoft.public.word.vba.general)