Asp net response write a file

Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search.

Your Answer

I hope this is a quick question I hope. The last time I did this I wrote a file to the webserver and then sent it to the client via Response object.

asp net response write a file

The question is, Is there a way to skip the writing of the physical file to to the webserver and go right asp net response write a file an object that represent the document to the response? This of course works if you want to write a text file. In case you want to write a.

This will give prompt the user to open or save test. NET objects in place of Table.

Add your solution here

The exact answer to the question depends on how do you have your report organized i. If you have a single string, you can use Response. Write to just write it. If you need a TextWriter, Response.

asp net response write a file

Output is what you want - that way you can skip writing to the disk and then using WriteFile. Also, if your content happened to be binary, you could use Response. OutputStream for that. You may also want to set Response. AddHeader "Content-Disposition", "attachment"if you asp net response write a file the user to see a save file dialog.

However, Content-Disposition is not necessarily honored, so the user may still get the report opened directly in the browser. Remember to set headers before you output the actual content!

Also, depending on the format of the report, you may want to set Response. The correct mime types are listed at the IANA site. Stack Overflow for Teams — Collaborate and share knowledge with a private best argumentative essay editing site. Create a free Team What is Teams?

asp net response write a file

Collectives on Stack Overflow.]

Thoughts on “Asp net response write a file

`